Download tests/test_api_indicators.py from MERLx/Aperture: direct link, hf CLI and curl.
- Browser
- Download file 1.12 kB
-
https://huggingface.co/spaces/MERLx/Aperture/resolve/fcb9daa4b394d997780098b3706e4f52bb70e072/tests/test_api_indicators.py
- Command line
-
hf download hf://spaces/MERLx/Aperture@fcb9daa4b394d997780098b3706e4f52bb70e072/tests/test_api_indicators.py
-
curl -L -o test_api_indicators.py https://huggingface.co/spaces/MERLx/Aperture/resolve/fcb9daa4b394d997780098b3706e4f52bb70e072/tests/test_api_indicators.py
1.12 kB
| import pytest | |
| from httpx import AsyncClient, ASGITransport | |
| from app.main import create_app | |
| from app.indicators import registry | |
| from app.indicators.base import BaseIndicator | |
| from app.models import AOI, TimeRange, IndicatorResult, StatusLevel, TrendDirection, ConfidenceLevel | |
| class StubIndicator(BaseIndicator): | |
| id = "stub" | |
| name = "Stub" | |
| category = "test" | |
| question = "Is this a stub?" | |
| estimated_minutes = 1 | |
| async def process(self, aoi: AOI, time_range: TimeRange) -> IndicatorResult: | |
| raise NotImplementedError | |
| async def client(temp_db_path): | |
| registry._indicators.clear() | |
| registry.register(StubIndicator()) | |
| app = create_app(db_path=temp_db_path) | |
| transport = ASGITransport(app=app) | |
| async with AsyncClient(transport=transport, base_url="http://test") as c: | |
| yield c | |
| async def test_list_indicators(client): | |
| resp = await client.get("/api/indicators") | |
| assert resp.status_code == 200 | |
| data = resp.json() | |
| assert len(data) >= 1 | |
| assert data[0]["id"] == "stub" | |
| assert data[0]["question"] == "Is this a stub?" | |