35 lines
1.4 KiB
Python
35 lines
1.4 KiB
Python
|
|
"""Tests für Planungs-Übungssuche (Intent, LLM-Rerank-Parser)."""
|
||
|
|
from planning_exercise_suggest import resolve_planning_exercise_intent
|
||
|
|
from planning_exercise_llm_rank import parse_planning_exercise_rank_response
|
||
|
|
|
||
|
|
|
||
|
|
def test_resolve_planning_exercise_intent_defaults():
|
||
|
|
assert resolve_planning_exercise_intent("", None) == "suggest_next"
|
||
|
|
assert resolve_planning_exercise_intent(" ", "suggest_next") == "suggest_next"
|
||
|
|
|
||
|
|
|
||
|
|
def test_resolve_planning_exercise_intent_keywords():
|
||
|
|
assert resolve_planning_exercise_intent("Vertiefung Partner", None) == "deepen_exercise"
|
||
|
|
assert resolve_planning_exercise_intent("nächste übung", None) == "suggest_next"
|
||
|
|
assert resolve_planning_exercise_intent("progression graph", None) == "progression_next"
|
||
|
|
|
||
|
|
|
||
|
|
def test_parse_planning_exercise_rank_response_filters_ids():
|
||
|
|
allowed = {10, 20, 30}
|
||
|
|
ranked, reasons = parse_planning_exercise_rank_response(
|
||
|
|
'{"ranked_ids":[20,999,20,10],"reasons":{"20":"Passt gut","999":"ignore"}}',
|
||
|
|
allowed,
|
||
|
|
)
|
||
|
|
assert ranked == [20, 10]
|
||
|
|
assert reasons[20] == "Passt gut"
|
||
|
|
assert 999 not in reasons
|
||
|
|
|
||
|
|
|
||
|
|
def test_parse_planning_exercise_rank_response_reasons_by_id_alias():
|
||
|
|
ranked, reasons = parse_planning_exercise_rank_response(
|
||
|
|
'{"ranked_ids":[5],"reasons_by_id":{"5":"Skill-Lücke"}}',
|
||
|
|
{5},
|
||
|
|
)
|
||
|
|
assert ranked == [5]
|
||
|
|
assert reasons[5] == "Skill-Lücke"
|