Fix brand-only and price-aware ranking

This commit is contained in:
Fiden committed 2026-08-07 17:58:41 +03:00
1 parent c7b19d1310
commit 2982161374
3 files changed
+132 -11

No files matched your search

+38 -1
View File
@@ -134,12 +134,49 @@ def test_makita_transliterations_share_the_same_brand_alias(
assert result.status == "ambiguous"
assert [candidate.sku for candidate in result.candidates] == [
"INS-0010",
"INS-0017",
"INS-0010",
"INS-0003",
]
def test_cheap_preference_orders_candidates_by_ascending_price(
matcher: CatalogMatcher,
) -> None:
result = matcher.match("шуруповерт как у макиты, только дешевле")
prices_by_sku = {item.sku: item.price for item in matcher.items}
candidate_prices = [
prices_by_sku[candidate.sku] for candidate in result.candidates
]
assert candidate_prices == sorted(candidate_prices)
@pytest.mark.parametrize(
"brand", ["ToolKraft", "toolkraft", "тулкрафт", "тул крафт"]
)
def test_brand_only_toolkraft_query_returns_catalog_items(
matcher: CatalogMatcher, brand: str
) -> None:
result = matcher.match(brand)
assert result.status == "ambiguous"
assert [candidate.sku for candidate in result.candidates] == [
"INS-0022",
"INS-0023",
"INS-0024",
]
def test_unknown_toolkraft_model_does_not_fall_back_to_brand_results(
matcher: CatalogMatcher,
) -> None:
result = matcher.match("ToolKraft TK-999")
assert result.status == "not_found"
assert result.candidates == []
@pytest.mark.parametrize("query", ["шурпуоверт на 12в", "шураыввавёрт на 12в"])
def test_product_type_survives_typos(matcher: CatalogMatcher, query: str) -> None:
result = matcher.match(query)