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>
This commit is contained in:
1 parent
827e6a2a11
commit
b276758ee1
152 files changed
+25846
-34
No files matched your search
@@ -0,0 +1,81 @@
|
||||
from app.discovery.mapping import verify_roundtrip
|
||||
from app.discovery.urlgen import generate_search_url
|
||||
|
||||
|
||||
CRITERIA = [
|
||||
{"id": "ram", "criterion": "ram_gb", "operator": ">=", "value": 24, "mandatory": True},
|
||||
{"id": "price", "criterion": "price_eur", "operator": "<=", "value": 2000, "mandatory": True},
|
||||
{"id": "weight", "criterion": "weight_kg", "operator": "<=", "value": 1.6, "mandatory": True},
|
||||
]
|
||||
|
||||
MAPPINGS = [
|
||||
{
|
||||
"criterion_key": "ram_gb",
|
||||
"external_filter_key": "17023",
|
||||
"source_value": "ab 24GB",
|
||||
"encoding": {"url_param": "xf"},
|
||||
"status": "VERIFIED",
|
||||
},
|
||||
{
|
||||
"criterion_key": "price_eur",
|
||||
"external_filter_key": "price",
|
||||
"source_value": None,
|
||||
"encoding": {"url_param": "maxp"},
|
||||
"status": "VERIFIED",
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
def test_ram_and_price_url_is_reproducible():
|
||||
first, internal = generate_search_url(
|
||||
category_url="https://geizhals.de/?cat=nb",
|
||||
criteria_items=CRITERIA,
|
||||
mappings=MAPPINGS,
|
||||
)
|
||||
second, _ = generate_search_url(
|
||||
category_url="https://geizhals.de/?cat=nb",
|
||||
criteria_items=CRITERIA,
|
||||
mappings=MAPPINGS,
|
||||
)
|
||||
assert first == second
|
||||
assert "xf=17023_ab+24GB" in first
|
||||
assert "maxp=2000" in first
|
||||
assert internal == ["weight_kg"]
|
||||
|
||||
|
||||
def test_internal_only_does_not_change_url():
|
||||
without_weight, _ = generate_search_url(
|
||||
category_url="https://geizhals.de/?cat=nb",
|
||||
criteria_items=CRITERIA[:2],
|
||||
mappings=MAPPINGS,
|
||||
)
|
||||
with_weight, internal = generate_search_url(
|
||||
category_url="https://geizhals.de/?cat=nb",
|
||||
criteria_items=CRITERIA,
|
||||
mappings=MAPPINGS,
|
||||
)
|
||||
assert without_weight == with_weight
|
||||
assert "weight_kg" in internal
|
||||
|
||||
|
||||
def test_broken_mapping_is_not_used():
|
||||
url, internal = generate_search_url(
|
||||
category_url="https://geizhals.de/?cat=nb",
|
||||
criteria_items=CRITERIA,
|
||||
mappings=[{**MAPPINGS[0], "status": "BROKEN"}, MAPPINGS[1]],
|
||||
)
|
||||
assert "17023" not in url
|
||||
assert "ram_gb" in internal
|
||||
|
||||
|
||||
def test_roundtrip_verifies_xf_and_maxp():
|
||||
assert verify_roundtrip(
|
||||
category_url="https://geizhals.de/?cat=nb",
|
||||
criterion=CRITERIA[0],
|
||||
mapping=MAPPINGS[0],
|
||||
)
|
||||
assert verify_roundtrip(
|
||||
category_url="https://geizhals.de/?cat=nb",
|
||||
criterion=CRITERIA[1],
|
||||
mapping=MAPPINGS[1],
|
||||
)
|
||||
Reference in new issue
Block a user