All checks were successful
Deploy Development / deploy (push) Successful in 46s
Test Suite / pytest-backend (push) Successful in 42s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Successful in 1m25s
- Added `stage_learning_goal_override` and `gap_trainer_supplements` parameters to `build_progression_path_gap_planning_context`, allowing for customized learning goals and additional trainer notes. - Updated `gapOfferContextDisplayLines` to include trainer supplements in the context display. - Enhanced `ExerciseProgressionPathBuilder` to utilize new parameters for improved gap fill offer handling. - Incremented application version to 0.8.214 to reflect these changes.
92 lines
3.6 KiB
Python
92 lines
3.6 KiB
Python
"""Tests Planungs-KI Phase D — planning_context für suggestExerciseAi."""
|
|
from planning_exercise_form_context import (
|
|
build_progression_gap_snapshot,
|
|
build_progression_path_gap_planning_context,
|
|
planning_context_prompt_variables,
|
|
sanitize_planning_context_for_ai,
|
|
)
|
|
|
|
|
|
def test_planning_context_prompt_variables_empty():
|
|
vars_ = planning_context_prompt_variables(None)
|
|
assert vars_["planning_context_json"] == "-"
|
|
assert vars_["has_planning_context"] == ""
|
|
|
|
|
|
def test_planning_context_prompt_variables_with_data():
|
|
vars_ = planning_context_prompt_variables({"source": "test", "goal_query": "Mae Geri"})
|
|
assert vars_["has_planning_context"] == "true"
|
|
assert "Mae Geri" in vars_["planning_context_json"]
|
|
|
|
|
|
def test_build_progression_path_gap_context():
|
|
ctx = build_progression_path_gap_planning_context(
|
|
goal_query="Mae Geri Perfektion",
|
|
primary_topic="Mae Geri",
|
|
progression_graph_id=3,
|
|
offer={
|
|
"source": "roadmap_unfilled",
|
|
"phase": "vertiefung",
|
|
"title_hint": "Koordination Mae Geri",
|
|
"roadmap_major_step_index": 2,
|
|
"from_title": "Schritt A",
|
|
"to_title": "Schritt B",
|
|
},
|
|
neighbor_before={"title": "Schritt A"},
|
|
neighbor_after={"title": "Schritt B"},
|
|
path_step_count=4,
|
|
major_step_count=5,
|
|
)
|
|
assert ctx["source"] == "progression_path_gap_fill"
|
|
assert ctx["roadmap_major_step_index"] == 2
|
|
assert ctx["neighbor_before_title"] == "Schritt A"
|
|
|
|
|
|
def test_sanitize_truncates_long_strings():
|
|
ctx = sanitize_planning_context_for_ai({"goal_query": "x" * 900})
|
|
assert len(ctx["goal_query"]) <= 800
|
|
|
|
|
|
def test_build_progression_gap_snapshot_includes_start_target_and_stage():
|
|
snap = build_progression_gap_snapshot(
|
|
goal_analysis={
|
|
"primary_topic": "Kumite Beinarbeit",
|
|
"start_assumption": "gleichförmige Steppbewegung",
|
|
"target_state": "explosiver Angriff mit Ausweichen",
|
|
"success_criteria": ["nachvollziehbarer Übergang"],
|
|
},
|
|
resolved_structured={"roadmap_notes": "Kindergruppe"},
|
|
stage_spec={
|
|
"learning_goal": "variable Rhythmen",
|
|
"load_profile": ["timing", "distanz"],
|
|
"success_criteria": ["Reaktion unter Druck"],
|
|
"anti_patterns": ["statisches Stehen"],
|
|
},
|
|
semantic_brief={"must_phrases": ["Beinarbeit"], "development_arc": ["grundlage", "anwendung"]},
|
|
)
|
|
assert snap["start_situation"] == "gleichförmige Steppbewegung"
|
|
assert snap["stage_learning_goal"] == "variable Rhythmen"
|
|
assert "timing" in snap["stage_load_profile"]
|
|
assert snap["roadmap_notes"] == "Kindergruppe"
|
|
|
|
|
|
def test_gap_planning_context_carries_snapshot_fields():
|
|
ctx = build_progression_path_gap_planning_context(
|
|
goal_query="Kumite Beinarbeit",
|
|
goal_analysis={"start_assumption": "Start", "target_state": "Ziel"},
|
|
stage_spec={"learning_goal": "Stufenziel", "load_profile": ["koordination"]},
|
|
)
|
|
assert ctx["start_situation"] == "Start"
|
|
assert ctx["stage_learning_goal"] == "Stufenziel"
|
|
|
|
|
|
def test_gap_planning_context_trainer_supplements_and_stage_override():
|
|
ctx = build_progression_path_gap_planning_context(
|
|
goal_query="Kumite",
|
|
stage_spec={"learning_goal": "Original"},
|
|
stage_learning_goal_override="Angepasstes Stufenziel",
|
|
gap_trainer_supplements="Nur Partnerübung, Kindergruppe",
|
|
)
|
|
assert ctx["stage_learning_goal"] == "Angepasstes Stufenziel"
|
|
assert ctx["gap_trainer_supplements"] == "Nur Partnerübung, Kindergruppe"
|