feat: complete pre-ai local completion v3
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
def test_canonical_identity_excludes_tenant_fiscal_context():
|
||||
from central.app.ai.kb_consolidation import canonical_product_id
|
||||
|
||||
a = canonical_product_id({"gtin": "7891234567895", "ncm": "22011000", "database": "A"})
|
||||
b = canonical_product_id({"gtin": "7891234567895", "ncm": "22019000", "database": "B"})
|
||||
assert a == b == "GTIN:7891234567895"
|
||||
|
||||
|
||||
def test_conflicts_are_conservative():
|
||||
from central.app.ai.kb_consolidation import NCM_CONFLICT, PACKAGING_VARIATION, classify_conflict
|
||||
|
||||
assert classify_conflict([
|
||||
{"gtin": "7891234567895", "ncm": "22011000", "normalized_description": "AGUA MINERAL", "package_quantity": "500"},
|
||||
{"gtin": "7891234567895", "ncm": "22019000", "normalized_description": "AGUA MINERAL", "package_quantity": "500"},
|
||||
]) == NCM_CONFLICT
|
||||
assert classify_conflict([
|
||||
{"gtin": "7891234567895", "ncm": "22011000", "normalized_description": "AGUA MINERAL", "package_quantity": "500"},
|
||||
{"gtin": "7891234567895", "ncm": "22011000", "normalized_description": "AGUA MINERAL", "package_quantity": "1L"},
|
||||
]) == PACKAGING_VARIATION
|
||||
|
||||
|
||||
def test_payload_audit_reports_observable_coverage():
|
||||
from central.app.ai.kb_consolidation import audit_payload
|
||||
|
||||
report = audit_payload({"products": [
|
||||
{"gtin": "7891234567895", "ncm": "22011000", "normalized_description": "AGUA", "observations": [{"database": "A"}]},
|
||||
{"gtin": "7891234567895", "ncm": "22019000", "normalized_description": "AGUA", "observations": [{"database": "B"}]},
|
||||
]}, historical_conflicts=163)
|
||||
assert report["historical_conflicts_reported"] == 163
|
||||
assert report["observable_conflicts_audited"] == 1
|
||||
assert report["unobservable_historical_conflicts"] == 162
|
||||
Reference in New Issue
Block a user