import requests import json def test_calendar_entries(): # Используемый токен token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIyOSIsImVtYWlsIjoidGVzdDJAZXhhbXBsZS5jb20iLCJleHAiOjE3NTg4NjQwMzV9.Ap4ZD5EtwhLXRtm6KjuFvXMlk6XA-3HtMbaGEu9jX6M" # Базовый URL base_url = "http://localhost:8004" # Заголовки с авторизацией headers = { "Authorization": f"Bearer {token}", "Content-Type": "application/json" } # Проверка здоровья сервиса response = requests.get(f"{base_url}/health") print("Health check:", response.status_code, response.text) # Проверка endpoint /api/v1/calendar/entries с GET response = requests.get(f"{base_url}/api/v1/calendar/entries", headers=headers) print("GET /api/v1/calendar/entries:", response.status_code) if response.status_code == 200: print("Response:", json.dumps(response.json(), indent=2)[:100] + "...") else: print("Error response:", response.text) # Проверка endpoint /api/v1/entry с POST (мобильное приложение) entry_data = { "date": "2023-11-15", "type": "period", "note": "Test entry", "symptoms": ["cramps", "headache"], "flow_intensity": "medium" } response = requests.post(f"{base_url}/api/v1/entry", headers=headers, json=entry_data) print("POST /api/v1/entry:", response.status_code) if response.status_code == 201: print("Response:", json.dumps(response.json(), indent=2)) else: print("Error response:", response.text) if __name__ == "__main__": test_calendar_entries()