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 / test (push) Has been cancelled

This commit is contained in:
2026-08-09 15:57:51 +00:00
parent f94e106c53
commit 12e199d8a3

View File

@@ -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)