All checks were successful
Deploy Development / deploy (push) Successful in 42s
Test Suite / pytest-backend (push) Successful in 44s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Successful in 1m18s
- Added `tzdata` installation in the Dockerfile to support time zone handling in Linux environments. - Increased `PIP_DEFAULT_TIMEOUT` and added retry logic for pip installations to enhance reliability during dependency installation. - Updated `requirements.txt` to conditionally include `tzdata` for Windows platforms, ensuring compatibility across different operating systems.
135 lines
5.1 KiB
Python
135 lines
5.1 KiB
Python
"""Tests Planungs-KI Phase D — planning_context für suggestExerciseAi."""
|
|
from planning_exercise_form_context import (
|
|
build_progression_entry_state,
|
|
build_progression_gap_snapshot,
|
|
build_progression_path_gap_planning_context,
|
|
enrich_gap_snapshot_with_entry_state,
|
|
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_build_progression_entry_state_from_prior_steps():
|
|
entry = build_progression_entry_state(
|
|
major_step_index=2,
|
|
prior_steps=[
|
|
{
|
|
"roadmap_major_step_index": 0,
|
|
"title": "Schritt-Stand",
|
|
"roadmap_phase": "einstieg",
|
|
"success_criteria": ["stabile Grundstellung"],
|
|
},
|
|
{
|
|
"roadmap_major_step_index": 1,
|
|
"title": "Mawashi Vorbereitung",
|
|
"roadmap_target_state": "Hüfte dreht vor dem Knie",
|
|
"roadmap_phase": "grundlage",
|
|
},
|
|
],
|
|
start_situation="Anfänger ohne Kumite-Erfahrung",
|
|
current_stage_start="Hüfte dreht vor dem Knie, sicherer Stand",
|
|
)
|
|
assert entry["entry_state"] == "Hüfte dreht vor dem Knie, sicherer Stand"
|
|
assert "Mawashi Vorbereitung" in entry["entry_state_detail"]
|
|
assert "stabile Grundstellung" in entry["prior_achievements"][0]
|
|
|
|
|
|
def test_enrich_gap_snapshot_with_entry_state():
|
|
snap = enrich_gap_snapshot_with_entry_state(
|
|
{"start_situation": "Basis", "stage_learning_goal": "Rhythmen"},
|
|
steps=[
|
|
{
|
|
"roadmap_major_step_index": 0,
|
|
"title": "A",
|
|
"success_criteria": ["Timing erkannt"],
|
|
}
|
|
],
|
|
major_step_index=1,
|
|
)
|
|
assert snap["entry_state"] == "Timing erkannt"
|
|
assert snap["prior_steps"][0]["title"] == "A"
|
|
|
|
|
|
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"
|