This commit is contained in:
@@ -167,6 +167,99 @@ def test_marketplace_matcher_does_not_promote_wide_price_refill_candidate():
|
||||
assert "strong_product_line_match" not in diagnostics.reasons
|
||||
|
||||
|
||||
def test_marketplace_matcher_rejects_partial_overlap_in_multi_spec_set():
|
||||
from services.marketplace_product_matcher import score_marketplace_match
|
||||
|
||||
diagnostics = score_marketplace_match(
|
||||
"【蘭蔻】玫瑰霜60ml+玫瑰精露150ml",
|
||||
"【蘭蔻】玫瑰霜60ml+玫瑰精露20ml",
|
||||
momo_price=18765,
|
||||
competitor_price=7999,
|
||||
)
|
||||
|
||||
assert diagnostics.score < 0.76
|
||||
assert diagnostics.hard_veto is True
|
||||
assert "volume_conflict" in diagnostics.reasons
|
||||
assert diagnostics.comparison_mode == "not_comparable"
|
||||
|
||||
|
||||
def test_marketplace_matcher_rejects_dosage_conflict():
|
||||
from services.marketplace_product_matcher import score_marketplace_match
|
||||
|
||||
diagnostics = score_marketplace_match(
|
||||
"品牌 葉黃素 10mg 60錠",
|
||||
"品牌 葉黃素 20mg 60錠",
|
||||
momo_price=990,
|
||||
competitor_price=890,
|
||||
)
|
||||
|
||||
assert diagnostics.score < 0.76
|
||||
assert diagnostics.hard_veto is True
|
||||
assert "dosage_conflict" in diagnostics.reasons
|
||||
|
||||
|
||||
def test_marketplace_matcher_rejects_product_type_conflict_even_when_line_matches():
|
||||
from services.marketplace_product_matcher import score_marketplace_match
|
||||
|
||||
diagnostics = score_marketplace_match(
|
||||
"理膚寶水 MelaB3 淡斑精華 30ml",
|
||||
"理膚寶水 MelaB3 淡斑化妝水 30ml",
|
||||
momo_price=1280,
|
||||
competitor_price=1180,
|
||||
)
|
||||
|
||||
assert diagnostics.score < 0.76
|
||||
assert diagnostics.hard_veto is True
|
||||
assert "type_conflict" in diagnostics.reasons
|
||||
assert diagnostics.comparison_mode == "not_comparable"
|
||||
|
||||
|
||||
def test_marketplace_matcher_rejects_same_count_different_unit_family():
|
||||
from services.marketplace_product_matcher import score_marketplace_match
|
||||
|
||||
diagnostics = score_marketplace_match(
|
||||
"品牌 保濕面膜10片",
|
||||
"品牌 保濕面膜10盒",
|
||||
momo_price=399,
|
||||
competitor_price=1990,
|
||||
)
|
||||
|
||||
assert diagnostics.score < 0.76
|
||||
assert diagnostics.hard_veto is True
|
||||
assert "count_conflict" in diagnostics.reasons
|
||||
|
||||
|
||||
def test_marketplace_matcher_marks_generic_bundle_words_as_unit_comparable():
|
||||
from services.marketplace_product_matcher import score_marketplace_match
|
||||
|
||||
diagnostics = score_marketplace_match(
|
||||
"【NARS】裸光蜜粉餅 雙件組 10g",
|
||||
"【NARS】裸光蜜粉餅 10g",
|
||||
momo_price=1999,
|
||||
competitor_price=1099,
|
||||
)
|
||||
|
||||
assert diagnostics.score < 0.76
|
||||
assert diagnostics.hard_veto is True
|
||||
assert "bundle_offer_conflict" in diagnostics.reasons
|
||||
assert diagnostics.comparison_mode == "unit_comparable"
|
||||
|
||||
|
||||
def test_marketplace_matcher_ignores_non_brand_bracket_copy():
|
||||
from services.marketplace_product_matcher import score_marketplace_match
|
||||
|
||||
diagnostics = score_marketplace_match(
|
||||
"【保濕組】理膚寶水 B5 修復霜 40ml",
|
||||
"理膚寶水 B5 修復霜 40ml",
|
||||
momo_price=699,
|
||||
competitor_price=679,
|
||||
)
|
||||
|
||||
assert diagnostics.score >= 0.76
|
||||
assert diagnostics.hard_veto is False
|
||||
assert "brand_conflict" not in diagnostics.reasons
|
||||
|
||||
|
||||
def test_batch_compare_top_uses_latest_momo_price_not_revenue(monkeypatch):
|
||||
from services import pchome_crawler
|
||||
|
||||
|
||||
Reference in New Issue
Block a user