Spaces:
Running
Running
Download tests/test_health.py from Rthur2003/crowncode-backend: direct link, hf CLI and curl.
- Browser
- Download file 1.22 kB
-
https://huggingface.co/spaces/Rthur2003/crowncode-backend/resolve/main/tests/test_health.py
- Command line
-
hf download hf://spaces/Rthur2003/crowncode-backend/tests/test_health.py
-
curl -L -o test_health.py https://huggingface.co/spaces/Rthur2003/crowncode-backend/resolve/main/tests/test_health.py
1.22 kB
| """Tests for health check and root endpoints.""" | |
| from __future__ import annotations | |
| from fastapi.testclient import TestClient | |
| def test_root_returns_api_info(client: TestClient) -> None: | |
| """Root endpoint should return API name, version, and status.""" | |
| response = client.get("/") | |
| assert response.status_code == 200 | |
| data = response.json() | |
| assert data["name"] == "CrownCode Backend API" | |
| assert data["status"] == "running" | |
| assert "version" in data | |
| def test_health_endpoint(client: TestClient) -> None: | |
| """Health endpoint should return ok status with services info.""" | |
| response = client.get("/api/health") | |
| assert response.status_code == 200 | |
| data = response.json() | |
| assert data["status"] == "ok" | |
| assert "services" in data | |
| def test_health_reports_model_inventory(client: TestClient) -> None: | |
| """Health says what actually loaded, not just that the process is up.""" | |
| data = client.get("/api/health").json() | |
| models = data["models"] | |
| assert "xai" in models and "available" in models["xai"] | |
| assert models["xai"]["ensembleTotal"] == 11 | |
| assert "wav2vec2" in models and "clap" in models and "meta" in models | |
| assert models["jobs"]["running"] >= 0 | |