2026-06-12 10:16:55 +02:00
|
|
|
"""Tests Katalog-Kontext für Progressionsgraph-Matching."""
|
|
|
|
|
from planning_catalog_context import (
|
|
|
|
|
ProgressionPlanningCatalogContext,
|
|
|
|
|
PlanningCatalogContextItem,
|
|
|
|
|
catalog_context_has_items,
|
|
|
|
|
merge_catalog_context_into_target,
|
|
|
|
|
)
|
|
|
|
|
from planning_exercise_profiles import PlanningTargetProfile
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_catalog_context_has_items():
|
|
|
|
|
assert not catalog_context_has_items(None)
|
|
|
|
|
assert not catalog_context_has_items(ProgressionPlanningCatalogContext())
|
|
|
|
|
assert catalog_context_has_items(
|
|
|
|
|
ProgressionPlanningCatalogContext(
|
|
|
|
|
focus_areas=[PlanningCatalogContextItem(id=3, is_primary=True)],
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_merge_catalog_context_into_target_sets_focus():
|
|
|
|
|
base = PlanningTargetProfile(sources=["query_only"])
|
|
|
|
|
merged = merge_catalog_context_into_target(
|
|
|
|
|
base,
|
|
|
|
|
ProgressionPlanningCatalogContext(
|
|
|
|
|
focus_areas=[PlanningCatalogContextItem(id=7, is_primary=True)],
|
|
|
|
|
training_types=[PlanningCatalogContextItem(id=2, is_primary=True)],
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
assert merged.focus_area_ids.get(7, 0) > 0.5
|
|
|
|
|
assert merged.training_type_ids.get(2, 0) > 0.5
|
|
|
|
|
assert "catalog_context" in merged.sources
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_normalize_planning_roadmap_with_catalog_context():
|
|
|
|
|
from progression_graph_planning_artifact import normalize_planning_roadmap_payload
|
|
|
|
|
|
|
|
|
|
out = normalize_planning_roadmap_payload(
|
|
|
|
|
{
|
|
|
|
|
"goal_query": "Deeskalation Kinder",
|
|
|
|
|
"planning_catalog_context": {
|
|
|
|
|
"focus_areas": [{"id": 4, "is_primary": True}],
|
|
|
|
|
"target_groups": [{"id": 9, "is_primary": True}],
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
assert out["planning_catalog_context"]["focus_areas"][0]["id"] == 4
|
2026-06-12 12:25:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_multistage_qa_splits_llm_highlights_from_fix_hints():
|
|
|
|
|
from planning_path_qa_pipeline import run_multistage_path_qa
|
|
|
|
|
|
|
|
|
|
result = run_multistage_path_qa(
|
|
|
|
|
off_topic_steps=[],
|
|
|
|
|
stripped_off_topic=[
|
|
|
|
|
{
|
|
|
|
|
"issue": "roadmap_unfilled",
|
|
|
|
|
"step_index": 1,
|
|
|
|
|
"reasons": ["Keine passende Übung"],
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
gaps=[],
|
|
|
|
|
llm_qa={
|
|
|
|
|
"overall_ok": True,
|
|
|
|
|
"quality_score": 0.88,
|
|
|
|
|
"recommendations": [
|
|
|
|
|
"Gute didaktische Progression",
|
|
|
|
|
"Optional: Vertiefung Koordination",
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
llm_applied=True,
|
|
|
|
|
)
|
|
|
|
|
hints = result["optimization_hints"]
|
|
|
|
|
llm_hints = [h for h in hints if h.get("issue") == "llm_recommendation"]
|
|
|
|
|
fix_hints = [h for h in hints if h.get("issue") != "llm_recommendation"]
|
|
|
|
|
assert len(llm_hints) >= 2
|
|
|
|
|
assert any(h.get("issue") == "roadmap_unfilled" for h in fix_hints)
|
|
|
|
|
assert result["qa_tiers"][2]["recommendations"][0].startswith("Gute didaktische")
|