decomposer: generate files for Maintain only the latest check result for each monitored target in concurrency-safe memory and expose it through the specified FastAPI current-status endpoint.
This commit is contained in:
28
tests/test_transform.py
Normal file
28
tests/test_transform.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from current_status import transform
|
||||
|
||||
|
||||
def test_preserves_prior_outputs_and_emits_current_status_implementation() -> None:
|
||||
source = {
|
||||
"service_specification": {"name": "monitor"},
|
||||
"target_management_implementation": {"module": "targets"},
|
||||
"endpoint_check_implementation": {"module": "checker"},
|
||||
}
|
||||
output = transform(source)
|
||||
|
||||
for key in source:
|
||||
assert output[key] == source[key]
|
||||
assert output[key] is not source[key]
|
||||
implementation = output["current_status_implementation"]
|
||||
assert implementation["endpoint"] == "GET /targets/{target_id}/status"
|
||||
assert implementation["no_check_yet"]["http_status"] == 200
|
||||
assert implementation["not_found"]["http_status"] == 404
|
||||
assert len(implementation["race_guards"]) == 2
|
||||
|
||||
|
||||
def test_rejects_missing_prior_contract_output() -> None:
|
||||
try:
|
||||
transform({})
|
||||
except ValueError as exc:
|
||||
assert str(exc) == "service_specification must be an object"
|
||||
else:
|
||||
raise AssertionError("expected ValueError")
|
||||
Reference in New Issue
Block a user