diff --git a/tests/test_transform.py b/tests/test_transform.py new file mode 100644 index 0000000..ecaaa40 --- /dev/null +++ b/tests/test_transform.py @@ -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")