diff --git a/tests/conftest.py b/tests/conftest.py index 4016ff0..e38e5e5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1 +1,29 @@ -# Env var setup that must run before app.config is imported. +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