From 710e7067b822e1b52e9637fa9942d2161eee9742 Mon Sep 17 00:00:00 2001 From: demo-bot Date: Sun, 9 Aug 2026 15:44:13 +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.py | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/tests/test_store.py b/tests/test_store.py index 5360d79..ea2d35e 100644 --- a/tests/test_store.py +++ b/tests/test_store.py @@ -2,15 +2,26 @@ import asyncio import pytest -from monitor_service.models import MonitorCreate -from monitor_service.store import MonitorStore +from app.models import CurrentStatus, MonitorCreate, MonitorUpdate, State +from app.store import MonitorNotFoundError, MonitorStore -@pytest.mark.anyio -async def test_concurrent_creates_are_not_lost() -> None: +async def test_atomic_update_does_not_lose_status() -> None: store = MonitorStore() - await asyncio.gather(*( - store.create(MonitorCreate(name=f"m-{index}", url=f"https://example.com/{index}")) - for index in range(30) - )) - assert len(await store.list()) == 30 + monitor = await store.create(MonitorCreate(name="one", url="https://example.com")) + status = CurrentStatus(state=State.UP) + await asyncio.gather( + store.update(monitor.id, MonitorUpdate(name="two")), + store.set_status(monitor.id, status), + ) + result = await store.get(monitor.id) + assert result.name == "two" + assert result.current_status.state == State.UP + + +async def test_delete_is_locked_and_missing_is_typed() -> None: + store = MonitorStore() + monitor = await store.create(MonitorCreate(name="one", url="https://example.com")) + await store.delete(monitor.id) + with pytest.raises(MonitorNotFoundError): + await store.get(monitor.id)