"""CARC-aware filter for Pipeline A.

Contractual / non-recoverable denials (CO-45, CO-26, CO-129) must be
excluded from rebill. CARCs that need operator review (PI-16, PI-96,
PI-15, PI-4, PI-110, OA-18, OA-23) must be surfaced as 'REVIEW' so the
operator can decide.
"""
from cyclone.rebill.carc_filter import (
    CarcDecision,
    decide_carc,
    EXCLUDED_CARCS,
    REVIEW_CARCS,
)


def test_co45_is_excluded():
    assert decide_carc(("CO-45",)) == CarcDecision.EXCLUDED


def test_co26_is_excluded():
    assert decide_carc(("CO-26",)) == CarcDecision.EXCLUDED


def test_co129_is_excluded():
    assert decide_carc(("CO-129",)) == CarcDecision.EXCLUDED


def test_pi16_is_review():
    assert decide_carc(("PI-16",)) == CarcDecision.REVIEW


def test_o18_is_review():
    """OA-18 is the duplicate noise — surface for review, don't auto-rebill."""
    assert decide_carc(("OA-18",)) == CarcDecision.REVIEW


def test_no_carc_is_rebill():
    assert decide_carc(()) == CarcDecision.REBILL


def test_mixed_excluded_wins():
    """If any CARC is excluded, the whole service is excluded."""
    assert decide_carc(("PI-16", "CO-45")) == CarcDecision.EXCLUDED


def test_sets_have_expected_members():
    assert "CO-45" in EXCLUDED_CARCS
    assert "PI-16" in REVIEW_CARCS
    assert "OA-18" in REVIEW_CARCS
