57 lines
1.9 KiB
Python
57 lines
1.9 KiB
Python
|
|
"""Tests Progressionsgraph-Auflösung für Planungs-KI (Phase C1)."""
|
||
|
|
from planning_exercise_progression import (
|
||
|
|
edge_matches_anchor_from,
|
||
|
|
filter_outgoing_progression_edges,
|
||
|
|
parse_successors_from_edges,
|
||
|
|
rank_progression_graph_rows,
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
def test_edge_matches_anchor_from_generic_edge():
|
||
|
|
assert edge_matches_anchor_from({"from_exercise_variant_id": None}, None)
|
||
|
|
assert edge_matches_anchor_from({"from_exercise_variant_id": None}, 5)
|
||
|
|
|
||
|
|
|
||
|
|
def test_edge_matches_anchor_from_variant_specific():
|
||
|
|
assert edge_matches_anchor_from({"from_exercise_variant_id": 3}, 3)
|
||
|
|
assert not edge_matches_anchor_from({"from_exercise_variant_id": 3}, None)
|
||
|
|
assert not edge_matches_anchor_from({"from_exercise_variant_id": 3}, 4)
|
||
|
|
|
||
|
|
|
||
|
|
def test_filter_outgoing_progression_edges():
|
||
|
|
edges = [
|
||
|
|
{"from_exercise_variant_id": None, "to_exercise_id": 10},
|
||
|
|
{"from_exercise_variant_id": 2, "to_exercise_id": 11},
|
||
|
|
]
|
||
|
|
filtered = filter_outgoing_progression_edges(edges, from_variant_id=2)
|
||
|
|
assert len(filtered) == 2
|
||
|
|
only_generic = filter_outgoing_progression_edges(edges, from_variant_id=None)
|
||
|
|
assert len(only_generic) == 1
|
||
|
|
assert only_generic[0]["to_exercise_id"] == 10
|
||
|
|
|
||
|
|
|
||
|
|
def test_parse_successors_from_edges():
|
||
|
|
ids, notes, variants = parse_successors_from_edges(
|
||
|
|
[
|
||
|
|
{
|
||
|
|
"to_exercise_id": 20,
|
||
|
|
"to_exercise_variant_id": 7,
|
||
|
|
"notes": " leicht ",
|
||
|
|
},
|
||
|
|
{"to_exercise_id": 21, "to_exercise_variant_id": None, "notes": ""},
|
||
|
|
]
|
||
|
|
)
|
||
|
|
assert ids == {20, 21}
|
||
|
|
assert notes[20] == "leicht"
|
||
|
|
assert variants[20] == 7
|
||
|
|
assert variants[21] is None
|
||
|
|
|
||
|
|
|
||
|
|
def test_rank_progression_graph_rows_prefers_variant_match():
|
||
|
|
rows = [
|
||
|
|
{"id": 1, "variant_match_count": 0, "outgoing_count": 5},
|
||
|
|
{"id": 2, "variant_match_count": 2, "outgoing_count": 1},
|
||
|
|
]
|
||
|
|
best = rank_progression_graph_rows(rows)
|
||
|
|
assert best["id"] == 2
|