from collections.abc import AsyncIterator import pytest from fastapi.testclient import TestClient from app.config import Settings from app.main import create_app from app.models import CurrentStatus, MonitorState, utc_now class FakeChecker: async def check(self, monitor_id: str, target_url: str) -> CurrentStatus: return CurrentStatus( state=MonitorState.UP, checked_at=utc_now(), latency_ms=3.5, http_status=204, ) @pytest.fixture def anyio_backend() -> str: return "asyncio" @pytest.fixture def client() -> AsyncIterator[TestClient]: with TestClient(create_app(Settings(), checker=FakeChecker())) as test_client: # type: ignore[arg-type] yield test_client