/
alexefan136
/
flowstack
Обзор
Документация
Войти
/
alexefan136
/
flowstack
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
core/engine/tests/test_main.py
71 строка
2 KB
Alexander Efanov
Обновление репозитория
15 июл 2026, 12:19
15 июл 2026, 12:19
76704c6
Код
Авторство
О чём код?
"""Тесты FastAPI endpoints.""" import pytest from fastapi.testclient import TestClient from core.engine.src.main import app @pytest.fixture def client(): """TestClient с запущенным lifespan (инициализирует executor).""" # ✅ Используем контекстный менеджер для запуска lifespan with TestClient(app) as test_client: yield test_client def test_health(client): response = client.get("/health") assert response.status_code == 200 data = response.json() assert data["status"] == "ok" assert "version" in data assert "env" in data def test_ready(client): response = client.get("/ready") assert response.status_code == 200 assert response.json()["status"] == "ready" def test_list_flows(client): response = client.get("/flows") assert response.status_code == 200 flows = response.json() assert isinstance(flows, list) assert len(flows) >= 2 flow_ids = [f["id"] for f in flows] assert "research" in flow_ids assert "review" in flow_ids def test_run_unknown_flow(client): response = client.post( "/runs", json={ "flow_id": "nonexistent", "input": {}, "stream": False, }, ) assert response.status_code == 404 assert "not found" in response.json()["detail"].lower() def test_run_research_flow(client): """Smoke-тест: запуск research flow с mock LLM.""" response = client.post( "/runs", json={ "flow_id": "research", "input": {"topic": "Искусственный интеллект"}, "stream": False, }, timeout=30.0, # LLM-вызовы могут быть медленными ) assert response.status_code == 200, f"Response: {response.text}" data = response.json() assert data["status"] == "success" assert data["output"] is not None assert data["run_id"] assert data["duration_ms"] >= 0