git-subtree-dir: fiscal git-subtree-mainline:d95165fc8fgit-subtree-split:102ba84500
53 lines
1.9 KiB
Python
53 lines
1.9 KiB
Python
from gti_fiscal_agent.ipi_auto_apply import ipi_write_decision
|
|
|
|
|
|
def _decision(ipi_status="IPI_RESOLVED", status="EXACT_NCM", ipi=None):
|
|
return {"status": status, "ipi_status": ipi_status, "classification": {"ipi": ipi}}
|
|
|
|
|
|
def test_numeric_null_current_is_eligible():
|
|
d = ipi_write_decision(_decision(ipi={"rate_kind": "NUMERIC", "rate_numeric": 3.25}), None)
|
|
assert d["eligible"] is True
|
|
assert d["proposed_value"] == 3.25
|
|
assert d["reason_code"] == "CHANGE_REQUIRED"
|
|
|
|
|
|
def test_numeric_same_value_is_not_eligible():
|
|
d = ipi_write_decision(_decision(ipi={"rate_kind": "NUMERIC", "rate_numeric": 3.25}), 3.25)
|
|
assert d["eligible"] is False
|
|
assert d["reason_code"] == "SAME_VALUE"
|
|
|
|
|
|
def test_numeric_different_value_is_eligible():
|
|
d = ipi_write_decision(_decision(ipi={"rate_kind": "NUMERIC", "rate_numeric": 3.25}), 0)
|
|
assert d["eligible"] is True
|
|
assert d["proposed_value"] == 3.25
|
|
|
|
|
|
def test_non_numeric_never_eligible():
|
|
d = ipi_write_decision(_decision(ipi={"rate_kind": "NON_NUMERIC", "rate_numeric": None}), None)
|
|
assert d["eligible"] is False
|
|
assert d["reason_code"] == "RATE_KIND_NON_NUMERIC"
|
|
|
|
|
|
def test_source_blank_never_eligible():
|
|
d = ipi_write_decision(_decision(ipi={"rate_kind": "BLANK", "rate_numeric": None}), None)
|
|
assert d["eligible"] is False
|
|
assert d["reason_code"] == "RATE_KIND_BLANK"
|
|
|
|
|
|
def test_ambiguous_ipi_status_never_eligible():
|
|
d = ipi_write_decision(_decision(ipi_status="IPI_CANDIDATES", ipi=None), None)
|
|
assert d["eligible"] is False
|
|
|
|
|
|
def test_no_match_never_eligible():
|
|
d = ipi_write_decision(_decision(ipi_status="NO_TIPI_MAPPING_FOUND", ipi=None), None)
|
|
assert d["eligible"] is False
|
|
|
|
|
|
def test_legacy_ncm_never_eligible():
|
|
d = ipi_write_decision(_decision(status="LEGACY_NCM", ipi_status="LEGACY_NCM"), None)
|
|
assert d["eligible"] is False
|
|
assert d["reason_code"] == "LEGACY_NCM"
|