Files
chat/tests/test_calendar_direct.py
Andrew K. Choi 64171196b6
All checks were successful
continuous-integration/drone/push Build is passing
calendar features
2025-09-26 14:45:00 +09:00

47 lines
1.7 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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()