diff --git a/backend/tests/test_rebill_spot_check.py b/backend/tests/test_rebill_spot_check.py index fe4c05d..52196e6 100644 --- a/backend/tests/test_rebill_spot_check.py +++ b/backend/tests/test_rebill_spot_check.py @@ -314,6 +314,28 @@ def test_full_pipeline_propagates_validate_error(): assert "quota" in str(excinfo.value.body).lower() +def test_claim_passes_shipped_sp40_local_validator(): + """The shipped SP40 local validator (25 R-codes) passes the ClaimOutput. + + The local validator at ``cyclone.parsers.validator.validate`` is the + structural pre-flight gate that mirrors what Edifabric checks at the + /v2/x12/validate level. Running the same claim through it confirms + the spot-check pipeline produces structurally-correct 837Ps even + when the live Edifabric API is unavailable. + """ + from cyclone.parsers.payer import PayerConfig + from cyclone.parsers.validator import validate as validate_claim + + visit = _visit() + claim = build_claim_output(visit) + report = validate_claim(claim, PayerConfig.co_medicaid()) + assert report.passed, ( + f"SP40 local validator rejected the claim: " + f"errors={[(i.rule, i.message) for i in report.errors]}" + ) + assert not report.errors, f"unexpected errors: {report.errors}" + + # --- Helpers -----------------------------------------------------------