#!/usr/bin/env python3 """ Простой тест для отладки Emergency API """ import asyncio import httpx import json async def test_simple_emergency(): # Получаем JWT токен async with httpx.AsyncClient() as client: # Авторизация login_data = { "email": "shadow85@list.ru", "password": "R0sebud1985" } print("🔐 Авторизация...") response = await client.post( "http://localhost:8000/api/v1/auth/login", json=login_data, headers={"Content-Type": "application/json"} ) if response.status_code != 200: print(f"❌ Ошибка авторизации: {response.status_code}") print(f"Response: {response.text}") return auth_data = response.json() jwt_token = auth_data.get("access_token") print(f"✅ JWT токен получен: {jwt_token[:50]}...") headers = { "Authorization": f"Bearer {jwt_token}", "Content-Type": "application/json" } # Тест health endpoint print("\n🏥 Проверяем health endpoint...") response = await client.get( "http://localhost:8002/health", headers=headers ) print(f"Health status: {response.status_code} - {response.text}") # Тест получения статистики print("\n📊 Тестируем получение статистики...") response = await client.get( "http://localhost:8002/api/v1/stats", headers=headers ) print(f"Stats status: {response.status_code}") if response.status_code == 200: print(f"Stats: {response.text}") else: print(f"Error: {response.text}") # Тест создания простого вызова print("\n📞 Тестируем создание вызова...") alert_data = { "alert_type": "medical", "latitude": 55.7558, "longitude": 37.6176, "description": "Тестовый вызов" } response = await client.post( "http://localhost:8002/api/v1/alert", json=alert_data, headers=headers ) print(f"Alert creation status: {response.status_code}") if response.status_code in [200, 201]: print(f"Alert created: {response.text}") else: print(f"Error: {response.text}") if __name__ == "__main__": asyncio.run(test_simple_emergency())