49 lines
1.6 KiB
Python
49 lines
1.6 KiB
Python
from decimal import Decimal
|
|
|
|
from app.discovery.ranking import rank_candidates
|
|
|
|
|
|
def test_shortlist_uses_product_score_only(profile, scoring_model, definitions):
|
|
ranked = rank_candidates(
|
|
profile=profile,
|
|
scoring_model=scoring_model,
|
|
definitions=definitions,
|
|
shortlist_size=1,
|
|
candidates=[
|
|
{
|
|
"id": "a",
|
|
"manufacturer": "Example",
|
|
"source_title": "Example Mobile 13 32GB",
|
|
"normalized_attributes": {
|
|
"ram_gb": 32,
|
|
"storage_gb": 1024,
|
|
"weight_kg": 1.2,
|
|
"battery_score": 90,
|
|
"display_score": 90,
|
|
"cpu_score": 90,
|
|
},
|
|
},
|
|
{
|
|
"id": "b",
|
|
"manufacturer": "Example",
|
|
"source_title": "Example Mobile 13 8GB",
|
|
"normalized_attributes": {
|
|
"ram_gb": 8,
|
|
"storage_gb": 1024,
|
|
"weight_kg": 1.2,
|
|
"battery_score": 90,
|
|
"display_score": 90,
|
|
"cpu_score": 90,
|
|
},
|
|
},
|
|
],
|
|
)
|
|
assert ranked[0]["id"] == "a"
|
|
assert ranked[0]["eligible"] is True
|
|
assert ranked[0]["candidate_status"] == "SHORTLISTED"
|
|
assert ranked[0]["product_score"] == Decimal("90.21")
|
|
assert ranked[1]["eligible"] is False
|
|
assert ranked[1]["candidate_status"] == "CANDIDATE"
|
|
assert "deal_score" not in ranked[0]
|
|
assert "price_score" not in ranked[0]
|