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.
Some checks failed
ci / validate (push) Has been cancelled

This commit is contained in:
2026-08-09 15:46:56 +00:00
parent ccb748a367
commit 9006cf883e

View File

@@ -2,26 +2,17 @@ import asyncio
import pytest import pytest
from app.models import CurrentStatus, MonitorCreate, MonitorUpdate, State from app.models import MonitorCreate
from app.store import MonitorNotFoundError, MonitorStore from app.store import MonitorStore
async def test_atomic_update_does_not_lose_status() -> None: @pytest.mark.asyncio
store = MonitorStore() async def test_concurrent_creates_are_retained_and_results_are_copies() -> None:
monitor = await store.create(MonitorCreate(name="one", url="https://example.com")) state = MonitorStore()
status = CurrentStatus(state=State.UP) payload = MonitorCreate(name="same", url="https://example.com")
await asyncio.gather( created = await asyncio.gather(*(state.create(payload) for _ in range(25)))
store.update(monitor.id, MonitorUpdate(name="two")), assert len(await state.list()) == 25
store.set_status(monitor.id, status), created[0].name = "mutated"
) persisted = await state.get(created[0].id)
result = await store.get(monitor.id) assert persisted is not None
assert result.name == "two" assert persisted.name == "same"
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)