Reject mismatched stove part sizes and label partial totals
This commit is contained in:
@@ -265,3 +265,5 @@ def test_works_only_are_a_valid_partial_total_when_material_prices_are_missing()
|
||||
assert out["materials"] is None
|
||||
assert out["total"] == out["works"]
|
||||
assert out["missing"] == [UNMATCHED["name"]]
|
||||
assert any("итог неполный" in note and "missing" in note
|
||||
for note in out["basis"]["notes"])
|
||||
|
||||
@@ -142,3 +142,31 @@ def test_match_prefers_deepseek_without_thinking_and_keeps_glm_fallback(monkeypa
|
||||
picked = asyncio.run(stove_match._ask(batch, 1, 300, time.monotonic()+10, "rid"))
|
||||
assert picked == [None]
|
||||
assert calls == [("deepseek", {"type": "disabled"}), ("glm", None)]
|
||||
|
||||
|
||||
def test_explicit_door_dimensions_exclude_wrong_catalog_size():
|
||||
wrong = {"code": "wrong", "name": "Дверка топочная, размеры 291х230х67 мм",
|
||||
"unit": "шт", "price_calc": 1200}
|
||||
right = {"code": "right", "name": "Дверка топочная, размеры 250х205х67 мм",
|
||||
"unit": "шт", "price_calc": 1400}
|
||||
found = {"status": "ok", "results": [wrong, right]}
|
||||
assert [row["code"] for row in stove_match._candidate_rows(
|
||||
found, "шт", "Дверка топочная 250×205")] == ["right"]
|
||||
assert len(stove_match._candidate_rows(found, "шт", "Дверка топочная")) == 2
|
||||
|
||||
|
||||
def test_cached_door_code_with_wrong_size_is_rejected(monkeypatch):
|
||||
deleted = []
|
||||
prices = {"region": "Москва", "zone": None, "valid_at": "III кв. 2026",
|
||||
"lines": [{"name": "Дверка топочная 250×205", "qty": 1, "unit": "шт", "code": None}]}
|
||||
wrong = {"code": "wrong", "name": "Дверка топочная, размеры 291х230х67 мм",
|
||||
"unit": "шт", "price_calc": 1200}
|
||||
monkeypatch.setattr(stove_match.stove_cache, "match_get", lambda key: {"code": "wrong"})
|
||||
monkeypatch.setattr(stove_match.stove_cache, "match_delete", lambda key: deleted.append(key))
|
||||
monkeypatch.setattr(stove_match.stove_cache, "match_put", lambda *args, **kw: None)
|
||||
monkeypatch.setattr(stove_match.fgis_ref, "find_resource_price", lambda **kw: {
|
||||
"status": "ok", "results": [wrong]})
|
||||
result = asyncio.run(stove_match.fill(
|
||||
prices, key_id=1, budget=300, deadline=time.monotonic()+10, request_id="rid"))
|
||||
assert result["lines"][0]["code"] is None
|
||||
assert len(deleted) == 1
|
||||
|
||||
Reference in New Issue
Block a user