diff --git a/scripts/test_plans_wp15.py b/scripts/test_plans_wp15.py index 910cb35..6be9b3c 100644 --- a/scripts/test_plans_wp15.py +++ b/scripts/test_plans_wp15.py @@ -110,11 +110,47 @@ def test_template_sections_ideal_supplement_roundtrip(): # ---------- Optional: Qdrant-Payload-Check (materialisierte Felder) ---------- def test_qdrant_materialized_fields_template(): - # Wenn Qdrant nicht erreichbar ist, Test überspringen + """ + Robust: Erst frisches Template anlegen (mit neuen Feldern), dann Qdrant-Scroll + mit Filter auf genau diese Template-ID. So treffen wir sicher einen Punkt, + der die materialisierten Felder enthält – unabhängig von älteren Datensätzen. + """ + # 1) Frisches Template erzeugen (mit ideal/supplement) + tpl = { + "name": "Std 90 v1.1 – materialized-check", + "discipline": "Karate", + "age_group": "Teenager", + "target_group": "Breitensport", + "total_minutes": 90, + "sections": [ + { + "name": "Warmup", + "target_minutes": 15, + "must_keywords": ["Reaktion"], + "ideal_keywords": ["Koordination"], + "supplement_keywords": ["Teamspiel"], + "forbid_keywords": [], + "capability_targets": {"Reaktionsfähigkeit": 2} + } + ], + "goals": ["Technik"], + "equipment_allowed": ["Bälle"], + "created_by": "tester", + "version": "1.1" + } + r = requests.post(f"{BASE}/plan_templates", json=tpl) + assert r.status_code == 200, r.text + tpl_id = r.json()["id"] + + # 2) Qdrant gezielt nach genau diesem Punkt scrollen (Payload enthält id) try: rq = requests.post( f"{QDRANT}/collections/{TPL_COLL}/points/scroll", - json={"with_payload": True, "limit": 1}, + json={ + "with_payload": True, + "limit": 1, + "filter": {"must": [{"key": "id", "match": {"value": tpl_id}}]} + }, timeout=2.0, ) except Exception: @@ -126,10 +162,9 @@ def test_qdrant_materialized_fields_template(): js = rq.json() pts = (js.get("result") or {}).get("points") or [] if not pts: - pytest.skip("Keine Punkte in plan_templates – überspringe") + pytest.skip("Keine Übereinstimmung in plan_templates – überspringe") payload = pts[0].get("payload") or {} - # Erwartet: materialisierte Listen vorhanden for key in [ "section_names", "section_must_keywords",