Support incomplete model suffixes

This commit is contained in:
Fiden committed 2026-08-07 18:47:52 +03:00
1 parent 7874c79534
commit 4286a92fcc
5 files changed
+108 -5

No files matched your search

+48
View File
@@ -177,6 +177,54 @@ def test_unknown_toolkraft_model_does_not_fall_back_to_brand_results(
assert result.candidates == []
@pytest.mark.parametrize(
("query", "sku"),
[
("Арс-12", "INS-0017"),
("АРС12", "INS-0017"),
("АРС-18", "INS-0018"),
("PW-12", "INS-0010"),
("TK-12", "INS-0024"),
("ТР-12", "INS-0003"),
],
)
def test_model_code_can_omit_only_its_final_letter(
matcher: CatalogMatcher, query: str, sku: str
) -> None:
result = matcher.match(query)
assert result.status == "matched"
assert [candidate.sku for candidate in result.candidates] == [sku]
@pytest.mark.parametrize(
"query",
[
"АРС-1",
"АРС-999",
"PW-90",
"TK-999",
"УШМ АРС-12",
],
)
def test_partial_model_does_not_guess_numeric_or_conflicting_models(
matcher: CatalogMatcher, query: str
) -> None:
result = matcher.match(query)
assert result.status == "not_found"
assert result.candidates == []
def test_complete_neighboring_model_keeps_exact_priority(
matcher: CatalogMatcher,
) -> None:
result = matcher.match("АРС-125")
assert result.status == "matched"
assert [candidate.sku for candidate in result.candidates] == ["INS-0020"]
@pytest.mark.parametrize("query", ["шурпуоверт на 12в", "шураыввавёрт на 12в"])
def test_product_type_survives_typos(matcher: CatalogMatcher, query: str) -> None:
result = matcher.match(query)
+1
View File
@@ -221,6 +221,7 @@ MORE_MESSAGE_BASELINE_RESULTS: dict[str, ExpectedResult] = {
"дрель удар мощно 900 хромированый анус долбить": ("ambiguous", ("INS-0009", "INS-0023", "INS-0002")),
"анус": ("not_found", ()),
"долбить": ("not_found", ()),
"Арс-12": ("matched", ("INS-0017",)),
}
EXPECTED_RESULTS = VALIDATED_MESSAGE_RESULTS | MORE_MESSAGE_BASELINE_RESULTS