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
Some checks failed
ci / test (push) Has been cancelled
This commit is contained in:
32
tests/test_store_and_config.py
Normal file
32
tests/test_store_and_config.py
Normal 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)
|
||||
Reference in New Issue
Block a user