All checks were successful
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Successful in 43s
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 1m26s
- Introduced a roadmap-first approach for retrieval, allowing for structured exercise suggestions based on stage specifications and major steps. - Added functionality to generate gap-fill offers for unfilled roadmap stages, improving the relevance of exercise recommendations. - Updated the `ExerciseProgressionPathBuilder` to support the new roadmap-first feature, enhancing user experience with clearer exercise paths. - Incremented application version to 0.8.206 and updated the database schema version to reflect these changes.
100 lines
3.8 KiB
Python
100 lines
3.8 KiB
Python
"""Tests Planungs-KI Phase F — Progressions-Roadmap Pipeline."""
|
|
from planning_progression_roadmap import (
|
|
PROMPT_SLUG_GOAL_ANALYSIS,
|
|
PROMPT_SLUG_ROADMAP,
|
|
PROMPT_SLUG_STAGE_SPEC,
|
|
MajorStep,
|
|
StageSpecArtifact,
|
|
build_goal_analysis,
|
|
build_roadmap_unfilled_gap_specs,
|
|
consolidate_micro_to_major,
|
|
develop_micro_objectives,
|
|
progression_roadmap_to_api_dict,
|
|
resolve_step_exercise_kind_filter,
|
|
run_progression_roadmap_pipeline,
|
|
stage_spec_exercise_kind_filter,
|
|
stage_spec_retrieval_query,
|
|
)
|
|
from planning_exercise_semantics import build_semantic_brief
|
|
|
|
|
|
def test_run_progression_roadmap_pipeline_major_step_count():
|
|
ctx = run_progression_roadmap_pipeline(
|
|
"Von Erlernen bis zur Perfektion des Fußtritts Mae Geri",
|
|
max_steps=5,
|
|
)
|
|
assert ctx.roadmap is not None
|
|
assert len(ctx.roadmap.major_steps) == 5
|
|
assert len(ctx.roadmap.micro_objectives) >= 6
|
|
assert len(ctx.stage_specs) == 5
|
|
assert ctx.goal_analysis is not None
|
|
assert "Mae" in ctx.goal_analysis.primary_topic or "mae" in ctx.goal_analysis.primary_topic.lower()
|
|
|
|
|
|
def test_consolidate_micro_to_major_reduces_count():
|
|
brief = build_semantic_brief("Mae Geri")
|
|
ga = build_goal_analysis("Mae Geri Perfektion", brief)
|
|
micro = develop_micro_objectives(brief, goal_analysis=ga, min_count=8)
|
|
majors, notes = consolidate_micro_to_major(micro, max_steps=5)
|
|
assert len(majors) == 5
|
|
if len(micro) > 5:
|
|
assert notes
|
|
assert all(m.learning_goal for m in majors)
|
|
|
|
|
|
def test_major_steps_have_learning_goals():
|
|
ctx = run_progression_roadmap_pipeline("Mae Geri Grundlagen", max_steps=3)
|
|
for step in ctx.roadmap.major_steps:
|
|
assert step.learning_goal.strip()
|
|
assert step.consolidates
|
|
|
|
|
|
def test_stage_spec_retrieval_query_includes_learning_goal():
|
|
brief = build_semantic_brief("Mae Geri Perfektion")
|
|
spec = StageSpecArtifact(
|
|
major_step_index=1,
|
|
learning_goal="Koordination und Präzision vertiefen",
|
|
load_profile=["präzision"],
|
|
exercise_type="kihon_einzel",
|
|
)
|
|
major = MajorStep(index=1, phase="vertiefung", learning_goal=spec.learning_goal, consolidates=["m3"])
|
|
q = stage_spec_retrieval_query(
|
|
semantic_brief=brief,
|
|
goal_query="Mae Geri Perfektion",
|
|
stage_spec=spec,
|
|
major_step=major,
|
|
)
|
|
assert "vertiefung" in q.lower()
|
|
assert "Koordination" in q or "Präzision" in q
|
|
|
|
|
|
def test_stage_spec_exercise_kind_filter_maps_combination():
|
|
spec = StageSpecArtifact(major_step_index=0, exercise_type="kombination")
|
|
assert stage_spec_exercise_kind_filter(spec) == ["combination"]
|
|
assert resolve_step_exercise_kind_filter(spec, ["simple"]) == ["simple"]
|
|
|
|
|
|
def test_build_roadmap_unfilled_gap_specs():
|
|
brief = build_semantic_brief("Mae Geri")
|
|
spec = StageSpecArtifact(major_step_index=2, learning_goal="Anwendung im Partnerdrill")
|
|
major = MajorStep(index=2, phase="anwendung", learning_goal=spec.learning_goal, consolidates=["m5"])
|
|
specs = build_roadmap_unfilled_gap_specs(
|
|
unfilled_specs=[(2, spec)],
|
|
major_steps_by_index={2: major},
|
|
steps=[{"exercise_id": 1, "title": "A"}, {"exercise_id": 2, "title": "B"}],
|
|
brief=brief,
|
|
goal_query="Mae Geri",
|
|
)
|
|
assert len(specs) == 1
|
|
assert specs[0]["source"] == "roadmap_unfilled"
|
|
assert specs[0]["phase"] == "anwendung"
|
|
|
|
|
|
def test_api_dict_exposes_prompt_slug_catalog():
|
|
ctx = run_progression_roadmap_pipeline("Mae Geri", max_steps=3, include_llm_roadmap=False)
|
|
api = progression_roadmap_to_api_dict(ctx)
|
|
assert api["prompt_slug_catalog"]["goal_analysis"] == PROMPT_SLUG_GOAL_ANALYSIS
|
|
assert api["prompt_slug_catalog"]["roadmap"] == PROMPT_SLUG_ROADMAP
|
|
assert api["prompt_slug_catalog"]["stage_spec"] == PROMPT_SLUG_STAGE_SPEC
|
|
assert api["prompt_slugs"] == []
|