File size: 1,123 Bytes
ae74af5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 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
@pytest.fixture
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
@pytest.mark.asyncio
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?"
|