From ba485e182b6eb51a67a19c9d66138e4040d89891 Mon Sep 17 00:00:00 2001 From: demo-bot Date: Sun, 9 Aug 2026 15:38:28 +0000 Subject: [PATCH] decomposer: generate deliverable files for Define the service contract and project architecture for the FastAPI endpoint monitoring service.; Implement the typed monitor CRUD API and concurrency-safe in-memory state according to the service design.; Implement secure on-demand endpoint checks with status updates, latency measurement, robust error handling, and redacted structured logs.; Add operational API endpoints and environment-driven runtime configuration to the monitoring service.; Create automated tests for the monitoring service.; Package the service with Docker and developer documentation.; Validate the complete project. --- tests/conftest.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 4016ff0..b3b4727 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1 +1,25 @@ -# Env var setup that must run before app.config is imported. +from collections.abc import AsyncIterator + +import httpx +import pytest +from httpx import ASGITransport, AsyncClient + +from monitor_service.api import create_app +from monitor_service.checker import CheckOutcome +from monitor_service.config import Settings +from monitor_service.models import CurrentStatus, MonitorState, utc_now + + +class StubChecker: + async def check(self, monitor_id: object, url: str) -> CheckOutcome: + return CheckOutcome(url.split("?", 1)[0], CurrentStatus( + state=MonitorState.up, checked_at=utc_now(), latency_ms=1.25, http_status=204 + )) + + +@pytest.fixture +async def client() -> AsyncIterator[AsyncClient]: + app = create_app(Settings(), checker=StubChecker()) # type: ignore[arg-type] + async with app.router.lifespan_context(app): + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as api: + yield api