From 12e199d8a3bf66bf4fad7f04623b35b96db1cdc1 Mon Sep 17 00:00:00 2001 From: demo-bot Date: Sun, 9 Aug 2026 15:57:51 +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/test_store_and_config.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/test_store_and_config.py diff --git a/tests/test_store_and_config.py b/tests/test_store_and_config.py new file mode 100644 index 0000000..0e3ae5c --- /dev/null +++ b/tests/test_store_and_config.py @@ -0,0 +1,32 @@ +from uuid import uuid4 + +import pytest +from pydantic import ValidationError + +from app.config import Settings +from app.models import MonitorCreate, MonitorState, StatusSnapshot +from app.store import MonitorStore + +pytestmark = pytest.mark.anyio + + +async def test_revision_prevents_stale_check_write() -> None: + store = MonitorStore() + monitor = await store.create(MonitorCreate(name="a", url="https://example.com")) + pending = await store.begin_check(monitor.id) + assert pending is not None + _, revision = pending + await store.update(monitor.id, MonitorCreate(name="b", url="https://example.org")) + saved = await store.finish_check( + monitor.id, revision, StatusSnapshot(state=MonitorState.UP), + ) + assert saved is False + assert (await store.get(monitor.id)).status.state is MonitorState.UNKNOWN # type: ignore[union-attr] + assert await store.begin_check(uuid4()) is None + + +async def test_settings_validation() -> None: + with pytest.raises(ValidationError): + Settings(check_timeout_seconds=0) + with pytest.raises(ValidationError): + Settings(max_redirects=99)