This commit is contained in:
2025-09-01 13:58:42 +03:00
parent 9459196804
commit 4cbdaf1b60
46 changed files with 880 additions and 863 deletions

79
test_api_direct.py Normal file
View File

@@ -0,0 +1,79 @@
#!/usr/bin/env python3
"""
Прямое тестирование API эндпоинтов
"""
import requests
import json
def test_api_endpoints():
"""Тестирование API эндпоинтов"""
base_url = "http://localhost:8000"
print("🧪 ПРЯМОЕ ТЕСТИРОВАНИЕ API")
print("=" * 40)
# Тест 1: Проверка доступности API
print("\n1⃣ Проверка доступности API...")
try:
response = requests.get(f"{base_url}/")
print(f"✅ API доступен: {response.status_code}")
except Exception as e:
print(f"❌ Ошибка: {e}")
return
# Тест 2: Тестирование эндпоинта svodka_ca/get_data
print("\n2⃣ Тестирование svodka_ca/get_data...")
try:
data = {
"getter": "get_data",
"modes": ["plan", "fact"],
"tables": ["ТиП", "Топливо"]
}
response = requests.post(f"{base_url}/svodka_ca/get_data", json=data)
print(f"📥 Результат: {response.status_code}")
if response.status_code == 200:
result = response.json()
print(f"✅ Успешно: {result}")
else:
try:
error_detail = response.json()
print(f"❌ Ошибка: {error_detail}")
except:
print(f"❌ Ошибка: {response.text}")
except Exception as e:
print(f"❌ Исключение: {e}")
# Тест 3: Тестирование эндпоинта svodka_pm/get_data
print("\n3⃣ Тестирование svodka_pm/get_data...")
try:
data = {
"getter": "single_og",
"id": "SNPZ",
"codes": [78, 79],
"columns": ["БП", "ПП"]
}
response = requests.post(f"{base_url}/svodka_pm/get_data", json=data)
print(f"📥 Результат: {response.status_code}")
if response.status_code == 200:
result = response.json()
print(f"✅ Успешно: {result}")
else:
try:
error_detail = response.json()
print(f"❌ Ошибка: {error_detail}")
except:
print(f"❌ Ошибка: {response.text}")
except Exception as e:
print(f"❌ Исключение: {e}")
print("\n🎯 Тестирование завершено!")
if __name__ == "__main__":
test_api_endpoints()