2026-05-23 12:02:57 +02:00
|
|
|
"""Tests Planungs-KI Phase E — Pfad-QA."""
|
|
|
|
|
from planning_exercise_path_builder import _pick_best_path_hit
|
2026-05-23 12:32:14 +02:00
|
|
|
from planning_exercise_path_qa import apply_llm_path_reorder
|
2026-05-23 12:02:57 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_pick_best_path_hit_prefers_semantic_score():
|
|
|
|
|
hits = [
|
|
|
|
|
{"id": 1, "title": "Mawashi", "score": 0.9, "semantic_score": 0.1},
|
|
|
|
|
{"id": 2, "title": "Mae Geri", "score": 0.75, "semantic_score": 0.85},
|
|
|
|
|
]
|
|
|
|
|
chosen = _pick_best_path_hit(hits, set())
|
|
|
|
|
assert chosen["id"] == 2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_pick_best_path_hit_skips_used():
|
|
|
|
|
hits = [{"id": 1, "title": "A", "score": 0.5, "semantic_score": 0.5}]
|
|
|
|
|
assert _pick_best_path_hit(hits, {1}) is None
|
2026-05-23 12:32:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_apply_llm_path_reorder_permutation():
|
|
|
|
|
steps = [{"exercise_id": 1}, {"exercise_id": 2}, {"exercise_id": 3}]
|
|
|
|
|
reordered, applied, notes = apply_llm_path_reorder(
|
|
|
|
|
steps,
|
|
|
|
|
{"ordered_step_indices": [0, 2, 1], "sequence_notes": ["Vertiefung vor Anwendung"]},
|
|
|
|
|
)
|
|
|
|
|
assert applied is True
|
|
|
|
|
assert [s["exercise_id"] for s in reordered] == [1, 3, 2]
|
|
|
|
|
assert notes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_apply_llm_path_reorder_invalid_ignored():
|
|
|
|
|
steps = [{"exercise_id": 1}, {"exercise_id": 2}]
|
|
|
|
|
reordered, applied, _ = apply_llm_path_reorder(steps, {"ordered_step_indices": [0, 0]})
|
|
|
|
|
assert applied is False
|
|
|
|
|
assert reordered == steps
|