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

96
test_ca_workflow.py Normal file
View File

@@ -0,0 +1,96 @@
#!/usr/bin/env python3
"""
Тестирование полного workflow с сводкой СА
"""
import requests
import os
import time
def test_ca_workflow():
"""Тестирование полного workflow с сводкой СА"""
base_url = "http://localhost:8000"
test_file = "python_parser/data/svodka_ca.xlsx"
print("🧪 ТЕСТ ПОЛНОГО WORKFLOW СВОДКИ СА")
print("=" * 50)
# Проверяем, что файл существует
if not os.path.exists(test_file):
print(f"❌ Файл {test_file} не найден")
return False
print(f"📁 Тестовый файл найден: {test_file}")
print(f"📏 Размер: {os.path.getsize(test_file)} байт")
# Шаг 1: Загружаем файл
print("\n1⃣ Загружаю файл сводки СА...")
try:
with open(test_file, 'rb') as f:
file_data = f.read()
files = {"file": ("svodka_ca.xlsx", file_data, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")}
response = requests.post(f"{base_url}/svodka_ca/upload", files=files)
print(f"📤 Результат загрузки: {response.status_code}")
if response.status_code == 200:
result = response.json()
print(f"✅ Файл загружен: {result}")
object_id = result.get('object_id', 'nin_excel_data_svodka_ca')
else:
print(f"❌ Ошибка загрузки: {response.status_code}")
try:
error_detail = response.json()
print(f"📋 Детали ошибки: {error_detail}")
except:
print(f"📋 Текст ошибки: {response.text}")
return False
except Exception as e:
print(f"❌ Ошибка загрузки: {e}")
return False
# Шаг 2: Получаем данные через геттер
print("\n2⃣ Получаю данные через геттер...")
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"✅ Данные получены успешно!")
print(f"📊 Размер ответа: {len(str(result))} символов")
# Показываем структуру данных
if isinstance(result, dict):
print(f"🔍 Структура данных:")
for key, value in result.items():
if isinstance(value, dict):
print(f" {key}: {len(value)} элементов")
else:
print(f" {key}: {type(value).__name__}")
else:
print(f"❌ Ошибка получения данных: {response.status_code}")
try:
error_detail = response.json()
print(f"📋 Детали ошибки: {error_detail}")
except:
print(f"📋 Текст ошибки: {response.text}")
return False
except Exception as e:
print(f"❌ Ошибка получения данных: {e}")
return False
print("\n🎯 Тестирование завершено успешно!")
return True
if __name__ == "__main__":
test_ca_workflow()