BuyingAgent/backend/tests/unit/test_discovery_ranking.py
Lars b276758ee1
All checks were successful
Deploy Development / deploy (push) Successful in 1m19s
Test Suite / pytest-backend (push) Successful in 31s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-checks (push) Successful in 28s
Stelle den Frontend-MVP und die v0.3-API auf develop bereit, damit Dev API und PWA zusammen deployen.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-04 13:04:59 +02:00

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]