Lerne Taxonomie und Trefferliste live von Geizhals, damit Wizard und Kandidaten echte Quelldaten nutzen.
Deploy Development / deploy (push) Successful in 1m49s
Test Suite / pytest-backend (push) Failing after 32s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-checks (push) Successful in 30s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-10-04 14:53:08 +02:00
1 parent d784248e28
commit 46857715df
25 files changed
+1614 -27

No files matched your search

@@ -68,6 +68,33 @@ def test_broken_mapping_is_not_used():
assert "ram_gb" in internal
def test_multiple_xf_filters_join_with_tilde():
url, _ = generate_search_url(
category_url="https://geizhals.de/?cat=nb",
criteria_items=[
{"criterion": "ram_gb", "operator": ">=", "value": 16},
{"criterion": "gpu", "operator": ">=", "value": 8},
],
mappings=[
{
"criterion_key": "ram_gb",
"external_filter_key": "12",
"source_value": "16384",
"encoding": {"url_param": "xf"},
"status": "VERIFIED",
},
{
"criterion_key": "gpu",
"external_filter_key": "7436",
"source_value": "8192",
"encoding": {"url_param": "xf"},
"status": "VERIFIED",
},
],
)
assert "xf=12_16384~7436_8192" in url or "xf=7436_8192~12_16384" in url
def test_roundtrip_verifies_xf_and_maxp():
assert verify_roundtrip(
category_url="https://geizhals.de/?cat=nb",
@@ -0,0 +1,42 @@
from pathlib import Path
from app.sources.geizhals.result_parser import parse_result_html, with_page
HTML = (Path(__file__).resolve().parents[2] / "fixtures" / "geizhals" / "nb-search-page.html").read_text(
encoding="utf-8"
)
def test_parser_reads_observed_gallery_cards() -> None:
payload = parse_result_html(HTML, page_url="https://geizhals.de/?cat=nb")
assert payload["blocked"] is False
assert payload["page_count"] == 4
assert payload["result_count"] == 6431
assert [item["source_external_id"] for item in payload["items"]] == ["1000001", "1000002"]
first = payload["items"][0]
assert first["source_url"] == "https://geizhals.de/acme-notebook-14-a1000001.html"
assert first["source_title"].startswith("Acme Notebook 14")
assert first["manufacturer"] == "Acme"
assert first["manufacturer_sku"] == "ACM-14-32"
assert first["best_price"] == "1298.00"
assert first["currency"] == "EUR"
assert first["availability"] == "in_stock"
assert first["seller_count"] == 8
assert first["raw_attributes"]["RAM"] == "32GB"
assert first["raw_attributes"]["Betriebssystem"] == "Linux"
assert first["normalized_attributes"]["ram_gb"] == 32
assert first["normalized_attributes"]["storage_gb"] == 1024
def test_challenge_html_is_not_turned_into_candidates() -> None:
payload = parse_result_html(
"<html><body>Enable JavaScript and cookies to continue</body></html>",
page_url="https://geizhals.de/?cat=nb",
)
assert payload["blocked"] is True
assert payload["items"] == []
def test_with_page_uses_geizhals_pg_parameter() -> None:
assert with_page("https://geizhals.de/?cat=nb&xf=17023_ab+16GB", 1) == "https://geizhals.de/?cat=nb&xf=17023_ab+16GB"
assert "pg=3" in with_page("https://geizhals.de/?cat=nb&xf=17023_ab+16GB", 3)
@@ -0,0 +1,76 @@
from pathlib import Path
from app.discovery.urlgen import generate_search_url
from app.sources.geizhals.taxonomy_parser import parse_taxonomy_html
HTML = (Path(__file__).resolve().parents[2] / "fixtures" / "geizhals" / "nb-category.html").read_text(
encoding="utf-8"
)
def test_parser_reads_href_filters_and_price_inputs() -> None:
payload = parse_taxonomy_html(
HTML,
category_ref="nb",
source_url="https://geizhals.de/?cat=nb",
)
keys = {item["external_filter_key"] for item in payload["filters"]}
assert {"12", "17023", "price", "12128", "7436", "82", "asuch"} <= keys
assert len(payload["filters"]) >= 12
live_ram = next(item for item in payload["filters"] if item["external_filter_key"] == "17023")
assert live_ram["label"] == "RAM"
ram = next(item for item in payload["filters"] if item["external_filter_key"] == "12")
assert ram["label"] == "RAM ab"
assert ram["filter_type"] == "NUMERIC_THRESHOLD"
assert any(option["source_value"] == "ab 16GB" for option in ram["options"])
assert ram["encoding"]["options"]["ab 16GB"] == "16384"
price = next(item for item in payload["filters"] if item["external_filter_key"] == "price")
assert price["filter_type"] == "NUMERIC_RANGE"
assert price["encoding"]["min_parameter"] == "bpmin"
assert price["encoding"]["max_parameter"] == "bpmax"
def test_learned_ram_and_price_encode_observed_geizhals_query() -> None:
payload = parse_taxonomy_html(
HTML,
category_ref="nb",
source_url="https://geizhals.de/?cat=nb",
)
ram = next(item for item in payload["filters"] if item["external_filter_key"] == "12")
price = next(item for item in payload["filters"] if item["external_filter_key"] == "price")
url, internal = generate_search_url(
category_url="https://geizhals.de/?cat=nb",
criteria_items=[
{"criterion": "geizhals:nb:12", "operator": ">=", "value": 16},
{"criterion": "geizhals:nb:price", "operator": "<=", "value": 1700},
],
mappings=[
{
"criterion_key": "geizhals:nb:12",
"external_filter_key": "12",
"source_value": "16384",
"encoding": ram["encoding"],
"status": "VERIFIED",
},
{
"criterion_key": "geizhals:nb:price",
"external_filter_key": "price",
"source_value": None,
"encoding": price["encoding"],
"status": "VERIFIED",
},
],
)
assert internal == []
assert "xf=12_16384" in url
assert "bpmax=1700" in url
def test_challenge_html_is_not_treated_as_taxonomy() -> None:
payload = parse_taxonomy_html(
"<html><body>Enable JavaScript and cookies to continue</body></html>",
category_ref="nb",
source_url="https://geizhals.de/?cat=nb",
)
assert payload["blocked"] is True
assert payload["filters"] == []
+6
View File
@@ -12,3 +12,9 @@ def test_database_url_uses_psycopg_and_explicit_fields() -> None:
assert settings.database_url == (
"postgresql+psycopg://buyingagent:secret@postgres:5432/buyingagent_test"
)
def test_geizhals_live_defaults_are_off_for_fixtures_flag() -> None:
settings = Settings(geizhals_use_fixtures=True, geizhals_playwright=False)
assert settings.geizhals_use_fixtures is True
assert settings.geizhals_playwright is False