Fix brand-only and price-aware ranking
This commit is contained in:
1 parent
c7b19d1310
commit
2982161374
3 files changed
+132
-11
No files matched your search
+38
-1
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user