update
This commit is contained in:
@@ -245,6 +245,110 @@ async def test_fix_fehlschlag_behaelt_befunde(monkeypatch):
|
||||
assert db.uj(sec["befunde"]) == ["Behebe (x): y"] # Aufträge bleiben sichtbar
|
||||
|
||||
|
||||
def test_marker_titel_erzeugen_keine_auftraege():
|
||||
"""Atom-Titel im Marker (a_n, A*-Suche) dürfen keine Mathe-/Stil-Aufträge
|
||||
erzeugen — der Fix darf Marker nie ändern, das wäre ein Endlos-Loop."""
|
||||
import db
|
||||
import guide
|
||||
from conftest import topic_anlegen
|
||||
topic = topic_anlegen("markerimmun")
|
||||
ziel = db.insert("lernziele", topic=topic, text="Kann X", status="aktiv")
|
||||
b_id = db.insert("bausteine", topic=topic, ziel_id=ziel, titel="B", ord=0, status="neu")
|
||||
a1 = db.insert("atome", topic=topic, titel="Folge a_n", typ="begriff", definition="d",
|
||||
status="neu", baustein_id=b_id, braucht=db.j([]))
|
||||
a2 = db.insert("atome", topic=topic, titel="A*-Suche", typ="begriff", definition="d",
|
||||
status="neu", baustein_id=b_id, braucht=db.j([]))
|
||||
lang = (f"<!-- atom: {a1} | Folge a_n -->\n<!-- atom: {a2} | A*-Suche -->\n"
|
||||
+ "Sauberer Fließtext ohne Formeln. " * 12)
|
||||
joined = " ".join(guide._det_auftraege(topic, {"id": b_id, "ord": 0}, lang, ""))
|
||||
assert "a_n" not in joined and "A*" not in joined
|
||||
assert "Formel" not in joined and "$-Zeichen" not in joined and "2^" not in joined
|
||||
|
||||
|
||||
def test_persistieren_dedup_mit_detail():
|
||||
"""Mehrere Befunde gleicher (art,item) mit verschiedenem detail = je eine Zeile."""
|
||||
import db
|
||||
import llm
|
||||
import qa
|
||||
from conftest import run_anlegen, topic_anlegen
|
||||
topic = topic_anlegen("persist")
|
||||
ctx = llm.Kontext(run_anlegen(topic), topic, "minimax")
|
||||
qa._persistieren(ctx, "guide", [{"art": "det_check", "item": "5", "detail": "A"},
|
||||
{"art": "det_check", "item": "5", "detail": "B"}])
|
||||
assert len(db.query("SELECT id FROM befunde WHERE status='offen'")) == 2
|
||||
qa._persistieren(ctx, "guide", [{"art": "det_check", "item": "5", "detail": "A"}])
|
||||
stat = {(b["detail"], b["status"]) for b in db.query("SELECT detail, status FROM befunde")}
|
||||
assert ("A", "offen") in stat and ("B", "repariert") in stat
|
||||
|
||||
|
||||
async def test_fix_offen_in_messen():
|
||||
"""Gescheiterter Fix (stage done, Rest-Aufträge) passiert das Gate nicht mehr."""
|
||||
import db
|
||||
import guide
|
||||
import llm
|
||||
from conftest import run_anlegen, topic_anlegen
|
||||
topic = topic_anlegen("fixoffen")
|
||||
ziel = db.insert("lernziele", topic=topic, text="Kann X", status="aktiv")
|
||||
b_id = db.insert("bausteine", topic=topic, ziel_id=ziel, titel="B", ord=0, status="neu")
|
||||
a = db.insert("atome", topic=topic, titel="A", typ="begriff", definition="d",
|
||||
status="neu", baustein_id=b_id, braucht=db.j([]))
|
||||
lang = f"<!-- atom: {a} | A -->\n" + "Wort " * 60
|
||||
db.insert("sections", baustein_id=b_id, stage="done", text_lang=lang,
|
||||
text_kompakt="- p", befunde=db.j(["KRITISCH (luecke): Atom-Inhalt fehlt"]))
|
||||
ctx = llm.Kontext(run_anlegen(topic), topic, "minimax")
|
||||
ctx.ebene = "guide"
|
||||
assert "fix_offen" in {b["art"] for b in guide.messen(ctx)}
|
||||
|
||||
|
||||
async def test_reparieren_bewegt_false_bei_identischem_text(monkeypatch):
|
||||
"""Fix ändert den Text nicht → reparieren meldet ehrlich False (Stillstand)."""
|
||||
import db
|
||||
import fake_agents
|
||||
import guide
|
||||
import llm
|
||||
from conftest import run_anlegen, topic_anlegen
|
||||
topic = topic_anlegen("bewegt")
|
||||
run = run_anlegen(topic)
|
||||
ziel = db.insert("lernziele", topic=topic, text="Kann X", status="aktiv")
|
||||
b_id = db.insert("bausteine", topic=topic, ziel_id=ziel, titel="B", ord=0, status="neu")
|
||||
a = db.insert("atome", topic=topic, titel="A", typ="begriff", definition="d",
|
||||
status="neu", baustein_id=b_id, braucht=db.j([]))
|
||||
lang = f"<!-- atom: {a} | A -->\n" + "Wort " * 60
|
||||
db.insert("sections", baustein_id=b_id, stage="fix", text_lang=lang,
|
||||
text_kompakt="- p", befunde=db.j(["Behebe (laenge): kürzen"]))
|
||||
monkeypatch.setitem(fake_agents._HANDLER, "Guide-Fix",
|
||||
lambda p: {"kompakt": "- p", "lang": lang}) # identisch
|
||||
ctx = llm.Kontext(run, topic, "minimax")
|
||||
ctx.ebene = "guide"
|
||||
bewegt = await guide.reparieren(
|
||||
ctx, [{"art": "det_check", "item": str(b_id), "detail": "kürzen"}])
|
||||
assert bewegt is False
|
||||
|
||||
|
||||
def test_stil_kein_fehlalarm_deutsch():
|
||||
"""Deutscher Satz mit Homographen an/will/Not → keine „englische Passage"."""
|
||||
import guide
|
||||
text = ("Wir passen die Kurve an und lesen den Wert an der Stelle ab, denn der"
|
||||
" Algorithmus will nicht in Not geraten und braucht das an dieser Stelle.")
|
||||
assert not any("englische Passage" in x for x in guide._stil_auftraege(text, "Langtext"))
|
||||
|
||||
|
||||
def test_pruefe_dich_norm_match():
|
||||
"""Frage-Matching ist Case/Whitespace-tolerant (Fix darf umformatieren)."""
|
||||
import db
|
||||
import guide
|
||||
from conftest import topic_anlegen
|
||||
topic = topic_anlegen("pruefe")
|
||||
ziel = db.insert("lernziele", topic=topic, text="Z", status="aktiv")
|
||||
b_id = db.insert("bausteine", topic=topic, ziel_id=ziel, titel="B", ord=0, status="neu")
|
||||
a = db.insert("atome", topic=topic, titel="A", typ="begriff", definition="d",
|
||||
status="neu", baustein_id=b_id, braucht=db.j([]))
|
||||
db.insert("artefakte", atom_id=a, typ="flashcard", status="verifiziert",
|
||||
inhalt=db.j({"frage": "Was ist ein Graph?", "antwort": "Knoten und Kanten."}))
|
||||
fragen = guide._pruefe_dich(b_id, "Prüfe dich: Was ist ein Graph?")
|
||||
assert len(fragen) == 1 and fragen[0]["antwort"] == "Knoten und Kanten."
|
||||
|
||||
|
||||
def test_katex_gate_und_markdown_hygiene(monkeypatch):
|
||||
import guide
|
||||
monkeypatch.delenv("CREATOR_FAKE_AGENTS", raising=False) # Gate echt laufen lassen
|
||||
|
||||
Reference in New Issue
Block a user