This commit is contained in:
39
tests/test_calendar_endpoint.py
Normal file
39
tests/test_calendar_endpoint.py
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python3
|
||||
import requests
|
||||
import json
|
||||
import sys
|
||||
|
||||
def test_calendar_entry_creation():
|
||||
token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIyOSIsImVtYWlsIjoidGVzdDJAZXhhbXBsZS5jb20iLCJleHAiOjE3NTg4NjQwMzV9.Ap4ZD5EtwhLXRtm6KjuFvXMlk6XA-3HtMbaGEu9jX6M"
|
||||
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": f"Bearer {token}"
|
||||
}
|
||||
|
||||
data = {
|
||||
"entry_date": "2025-09-30", # Использую другую дату, чтобы избежать конфликта
|
||||
"entry_type": "period",
|
||||
"flow_intensity": "medium",
|
||||
"notes": "Test entry created via Python script"
|
||||
}
|
||||
|
||||
url = "http://localhost:8004/api/v1/calendar/entries"
|
||||
|
||||
try:
|
||||
response = requests.post(url, headers=headers, json=data)
|
||||
print(f"Статус ответа: {response.status_code}")
|
||||
print(f"Текст ответа: {response.text}")
|
||||
|
||||
if response.status_code == 201:
|
||||
print("✅ Тест успешно пройден! Запись календаря создана.")
|
||||
return 0
|
||||
else:
|
||||
print(f"❌ Тест не пройден. Код ответа: {response.status_code}")
|
||||
return 1
|
||||
except Exception as e:
|
||||
print(f"❌ Ошибка при выполнении запроса: {str(e)}")
|
||||
return 1
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(test_calendar_entry_creation())
|
||||
Reference in New Issue
Block a user