feat: close autonomous operations for blocked products
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
from central.app.operational_state import blocker_fingerprint, classify_product_state, should_retry_blocker, summarize_operational_states
|
||||
|
||||
|
||||
def test_blocked_product_does_not_make_other_products_fail():
|
||||
states = [
|
||||
classify_product_state({"CODIGO": "1"}, {"status": "EXACT_NCM"}),
|
||||
classify_product_state({"CODIGO": "2"}, {"status": "AMBIGUOUS"}),
|
||||
]
|
||||
|
||||
summary = summarize_operational_states(states)
|
||||
|
||||
assert summary["COMPLETE"] == 1
|
||||
assert summary["BLOCKED_CONFLICT"] == 1
|
||||
assert summary["AGENT_HEALTH"] == "HEALTHY"
|
||||
|
||||
|
||||
def test_blocker_fingerprint_deduplicates_same_input():
|
||||
first = blocker_fingerprint("tenant", "company", "P1", "CFOP", "MISSING_EVIDENCE", "engine-v1")
|
||||
second = blocker_fingerprint("tenant", "company", "P1", "CFOP", "MISSING_EVIDENCE", "engine-v1")
|
||||
|
||||
assert first == second
|
||||
|
||||
|
||||
def test_retry_only_when_input_fingerprint_changes():
|
||||
assert should_retry_blocker("old", "new") is True
|
||||
assert should_retry_blocker("old", "old") is False
|
||||
|
||||
|
||||
def test_technical_failure_is_not_healthy_when_present():
|
||||
summary = summarize_operational_states([{"state": "FAILED_TECHNICAL"}])
|
||||
|
||||
assert summary["FAILED_TECHNICAL"] == 1
|
||||
assert summary["AGENT_HEALTH"] == "DEGRADED"
|
||||
Reference in New Issue
Block a user