Spaces:
Runtime error
Runtime error
Download backend/tests/test_api.py from DestinyOtto/astris-backend: direct link, hf CLI and curl.
- Browser
- Download file 1.39 kB
-
https://huggingface.co/spaces/DestinyOtto/astris-backend/resolve/main/backend/tests/test_api.py
- Command line
-
hf download hf://spaces/DestinyOtto/astris-backend/backend/tests/test_api.py
-
curl -L -o test_api.py https://huggingface.co/spaces/DestinyOtto/astris-backend/resolve/main/backend/tests/test_api.py
1.39 kB
| from fastapi.testclient import TestClient | |
| from app.main import app | |
| client = TestClient(app) | |
| def test_health_assets_and_model_card(): | |
| health = client.get("/api/health") | |
| assert health.status_code == 200 | |
| assert health.json()["backend"] == "FastAPI + LangGraph" | |
| assets = client.get("/api/assets") | |
| assert assets.status_code == 200 | |
| assert any(row["asset"]["asset_id"] == "HSM-GBX-017" for row in assets.json()) | |
| model_card = client.get("/api/model-card").json() | |
| assert model_card["embeddings"]["store"] == "Chroma persistent local collection" | |
| def test_case_run_and_sse_stream(): | |
| response = client.post( | |
| "/api/cases/CASE-GBX17-LUBE-STARVATION/run", | |
| json={"query": "Diagnose GBX-17", "case_id": "CASE-GBX17-LUBE-STARVATION"}, | |
| ) | |
| assert response.status_code == 200 | |
| assert response.json()["risk"]["risk_level"] == "critical" | |
| with client.stream("GET", "/api/review/stream?case_id=CASE-GBX17-LUBE-STARVATION") as stream: | |
| text = "".join(stream.iter_text()) | |
| assert "event: tool_start" in text | |
| assert "event: finish" in text | |
| with client.stream("GET", "/api/chat/stream?query=Why%20is%20this%20critical%3F&case_id=CASE-GBX17-LUBE-STARVATION&agent_mode=structured") as stream: | |
| chat_text = "".join(stream.iter_text()) | |
| assert "event: text_delta" in chat_text | |
| assert "event: finish" in chat_text | |