29 lines
1.0 KiB
Python
29 lines
1.0 KiB
Python
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")
|