DealDocumentScreening/tests/unit/test_credits.py
2026-08-12 21:29:36 +03:00

35 lines
991 B
Python

"""Credits policy unit tests — pure decision logic (DB behavior is integration)."""
from __future__ import annotations
from contract_check.core.credits import NON_REFUNDABLE_INFRA_ONLY, should_refund
def test_policy_all_refunds_everything() -> None:
for failure in (
"extraction_failed",
"ocr_failed",
"llm_quota",
"llm_invalid_output",
"llm_timeout",
"infra",
"unknown",
):
assert should_refund(failure, "all") is True
def test_policy_infra_only_skips_extraction_failed() -> None:
assert should_refund("extraction_failed", "infra_only") is False
for failure in (
"ocr_failed",
"llm_quota",
"llm_invalid_output",
"llm_timeout",
"infra",
"unknown",
):
assert should_refund(failure, "infra_only") is True
def test_non_refundable_set_is_just_extraction_failed() -> None:
assert NON_REFUNDABLE_INFRA_ONLY == frozenset({"extraction_failed"})