shinkan-jinkendo/backend/tests/test_planning_catalog_context.py
Lars f3710ac0a1
All checks were successful
Deploy Development / deploy (push) Successful in 45s
Test Suite / pytest-backend (push) Successful in 43s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m15s
Enhance Planning Catalog Context Integration in Progression Path
- Updated `PROJECT_STATUS.md` to reflect the addition of the Planning AI Progression Graph and its context in the roadmap.
- Enhanced `DOMAIN_MODEL.md` with details on the new `planning_catalog_context` features, allowing trainers to manage curriculum stages and context.
- Added tests in `test_planning_catalog_context.py` to validate the separation of LLM highlights from fix hints during QA processes.
- Updated `HANDOVER.md` and `PLANNING_KI_ROADMAP.md` to reflect the latest app version and improvements in the planning context.
- Enhanced frontend components to support the new planning catalog context, including updates to `ExerciseProgressionPathBuilder` and `ProgressionGraphEditor`.
- Bumped version to 0.8.233 to reflect the new features and improvements.
2026-06-12 12:25:52 +02:00

79 lines
2.7 KiB
Python

"""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
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")