All checks were successful
continuous-integration/drone/push Build is passing
48 lines
1.8 KiB
Python
48 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
||
|
||
import requests
|
||
import json
|
||
import sys
|
||
|
||
def test_calendar_entry_creation():
|
||
# Данные для тестового запроса
|
||
data = {
|
||
"entry_date": "2025-09-30",
|
||
"entry_type": "period",
|
||
"flow_intensity": "medium",
|
||
"notes": "Test entry created via Python script"
|
||
}
|
||
|
||
url = "http://localhost:8888/api/v1/calendar/entries"
|
||
|
||
try:
|
||
print(f"Отправка запроса на {url} с данными:")
|
||
print(json.dumps(data, indent=2))
|
||
|
||
response = requests.post(url, json=data)
|
||
print(f"Статус ответа: {response.status_code}")
|
||
|
||
if response.status_code == 201:
|
||
print("Содержимое ответа:")
|
||
print(json.dumps(response.json(), indent=2))
|
||
print("✅ Тест успешно пройден! Запись календаря создана.")
|
||
|
||
# Проверим, что запись действительно создана с помощью GET-запроса
|
||
get_response = requests.get(url)
|
||
if get_response.status_code == 200:
|
||
entries = get_response.json()
|
||
print(f"Количество записей в календаре: {len(entries)}")
|
||
print("Последняя запись:")
|
||
print(json.dumps(entries[-1], indent=2))
|
||
|
||
return 0
|
||
else:
|
||
print(f"❌ Тест не пройден. Код ответа: {response.status_code}")
|
||
print(f"Текст ответа: {response.text}")
|
||
return 1
|
||
except Exception as e:
|
||
print(f"❌ Ошибка при выполнении запроса: {str(e)}")
|
||
return 1
|
||
|
||
if __name__ == "__main__":
|
||
sys.exit(test_calendar_entry_creation()) |