update
This commit is contained in:
65
backend/tests/test_guide_qa.py
Normal file
65
backend/tests/test_guide_qa.py
Normal file
@@ -0,0 +1,65 @@
|
||||
"""Guide-QA: Fehler-Injektion auf Mini-Guide-Karten — deterministisch, ohne LLM."""
|
||||
|
||||
import guide_qa as gq
|
||||
import qa
|
||||
|
||||
|
||||
def _card(block, md):
|
||||
return {"block": block, "block_norm": block.casefold(), "md": md}
|
||||
|
||||
|
||||
AUSF = ("<!-- section: Alpha -->\n<!-- compact -->\n- m\n<!-- ausführlich -->\n"
|
||||
"Einstieg in den Block.\n"
|
||||
"<!-- sub: beginner | Kantenzug Definition -->\n"
|
||||
"Ein Kantenzug verbindet Knoten über Kanten im Graphen.\n")
|
||||
|
||||
|
||||
def test_ausfuehrlich_extrahiert_lerntext():
|
||||
assert gq._ausfuehrlich(AUSF).startswith("\nEinstieg")
|
||||
assert gq._ausfuehrlich("nur text") == "nur text"
|
||||
|
||||
|
||||
def test_marker_fehlend():
|
||||
cards = [_card("Alpha", AUSF)]
|
||||
rel = {"alpha": {"kantenzug definition", "fehlender aspekt"}}
|
||||
out = gq.marker_fehlend(cards, rel)
|
||||
assert out == ["Alpha · fehlender aspekt"]
|
||||
|
||||
|
||||
def test_ziel_ohne_anker():
|
||||
cards = [_card("Alpha", AUSF)]
|
||||
ziele = [{"block_norm": "alpha", "ziel_id": "z1", "text": "Kantenzug im Graphen erklären"},
|
||||
{"block_norm": "alpha", "ziel_id": "z2", "text": "Adjazenzmatrix aufstellen können"}]
|
||||
out = gq.ziel_ohne_anker(cards, ziele)
|
||||
assert len(out) == 1 and "z2" in out[0]
|
||||
|
||||
|
||||
def test_laengen_ausreisser():
|
||||
duenn = _card("Alpha", "<!-- ausführlich -->\nkurz")
|
||||
ok = _card("Beta", "<!-- ausführlich -->\n" + "x" * 500)
|
||||
out = gq.laengen_ausreisser([duenn, ok], {"alpha": {"s1"}, "beta": {"s1"}})
|
||||
assert [x["block"] for x in out] == ["Alpha"]
|
||||
|
||||
|
||||
def test_redundanz_findet_absatz_doppel():
|
||||
a = "Der Kantenzug verbindet Knoten über mehrere Kanten und darf Knoten wiederholen. " * 3
|
||||
b = "Der Kantenzug verbindet Knoten über mehrere Kanten und darf Knoten wiederholen, genau. " * 3
|
||||
c = "Völlig anderes Thema: Matrizen, Determinanten und lineare Abbildungen im Vektorraum. " * 3
|
||||
cards = [_card("Alpha", f"<!-- ausführlich -->\n{a}\n\n{c}"),
|
||||
_card("Beta", f"<!-- ausführlich -->\n{b}")]
|
||||
out = gq.redundanz(cards)
|
||||
assert len(out) == 1 and out[0]["a"].startswith("Alpha")
|
||||
|
||||
|
||||
def test_lesbarkeit_fail_open(monkeypatch):
|
||||
def kaputt(md_by_num):
|
||||
raise RuntimeError("Modell fehlt")
|
||||
monkeypatch.setattr(gq.readability, "rate_sections", kaputt)
|
||||
assert gq.lesbarkeit([_card("Alpha", AUSF)]) == []
|
||||
|
||||
|
||||
def test_note_guide_kalibrierung():
|
||||
"""Gewicht = Punktabzug bei 100 %: 10 % fachlich falsch × 3.0 → 7.0; ungemessen zählt nicht."""
|
||||
assert qa.note({"fachlich_falsch": 0.1}, gq.NOTE_GEWICHTE_GUIDE) == 7.0
|
||||
ohne = {"marker_fehlend": 0.0, "ziel_ohne_anker": 0.0}
|
||||
assert qa.note(ohne, gq.NOTE_GEWICHTE_GUIDE) == 10.0
|
||||
Reference in New Issue
Block a user