update
This commit is contained in:
@@ -87,6 +87,64 @@ async def test_hartnaeckig_vergessene_wird_befund(monkeypatch):
|
||||
assert befunde[0]["item"] == str(c)
|
||||
|
||||
|
||||
async def test_konsens_erhaelt_nachbelege_geprueft_und_id(monkeypatch):
|
||||
"""Neu-Konsens darf bestätigte Zeilen nicht löschen: id, geprueft-Cache und
|
||||
nachgesuchte Belege bleiben, Belege werden vereint."""
|
||||
topic, (q1, q2), ctx = _seed(art="thema", n_quellen=2)
|
||||
best = db.insert("soll", topic=topic, punkt="Alpha", status="bestaetigt",
|
||||
belege=db.j([{"quelle": q1, "zitat": "Zitat Alpha"}]),
|
||||
geprueft=db.j([q2]))
|
||||
a1 = _kandidat(topic, "Alpha", q1)
|
||||
a2 = _kandidat(topic, "Alpha", q2)
|
||||
|
||||
def judge(prompt):
|
||||
if "NACHRUNDE" in prompt:
|
||||
return []
|
||||
return [{"punkt": "Alpha", "kandidaten": [a1, a2]}]
|
||||
|
||||
monkeypatch.setitem(fake_agents._HANDLER, "Korpus-Soll-Konsens", judge)
|
||||
assert await korpus._konsens(ctx) == 1
|
||||
row = db.one("SELECT * FROM soll WHERE topic=? AND status='bestaetigt'", (topic,))
|
||||
assert row["id"] == best # id stabil (kein DELETE+INSERT)
|
||||
assert db.uj(row["geprueft"]) == [q2] # geprueft-Cache erhalten
|
||||
assert {b["quelle"] for b in db.uj(row["belege"])} == {q1, q2} # Belege-Union
|
||||
|
||||
|
||||
async def test_soll_resume_ohne_doppelkandidaten(monkeypatch, tmp_path):
|
||||
"""Abgebrochener Extraktions-Pass: der Resume darf keine Doppel-Kandidaten legen."""
|
||||
topic = topic_anlegen("resume-soll", art="uni")
|
||||
snap = tmp_path / "q.md"
|
||||
snap.write_text("Der wichtige Punkt steht hier im Text.", encoding="utf-8")
|
||||
q = db.insert("quellen", topic=topic, art="datei", titel="q",
|
||||
snapshot=str(snap), hash="h", status="neu")
|
||||
db.insert("soll", topic=topic, punkt="Der wichtige Punkt", status="kandidat",
|
||||
belege=db.j([{"quelle": q, "zitat": "Der wichtige Punkt"}]))
|
||||
ctx = llm.Kontext(run_anlegen(topic), topic, "minimax")
|
||||
ctx.ebene = "korpus"
|
||||
monkeypatch.setitem(fake_agents._HANDLER, "Korpus-Soll",
|
||||
lambda p: [{"punkt": "Der wichtige Punkt",
|
||||
"zitat": "Der wichtige Punkt steht hier"}])
|
||||
await korpus._soll_extrahieren(ctx)
|
||||
kand = db.query("SELECT id FROM soll WHERE topic=? AND status='kandidat'", (topic,))
|
||||
assert len(kand) == 1 # Leiche gelöscht, genau ein Kandidat
|
||||
|
||||
|
||||
async def test_uni_soll_leer_faellt_zu(monkeypatch, tmp_path):
|
||||
"""uni-Topic ohne bestätigten Punkt: kein Auto-Freeze, Gate blockt E1."""
|
||||
topic = topic_anlegen("unileer", art="uni")
|
||||
snap = tmp_path / "q.md"
|
||||
snap.write_text("Nur Fülltext ohne lernbaren Punkt.", encoding="utf-8")
|
||||
db.insert("quellen", topic=topic, art="datei", titel="q",
|
||||
snapshot=str(snap), hash="h", status="neu")
|
||||
ctx = llm.Kontext(run_anlegen(topic), topic, "minimax")
|
||||
ctx.ebene = "korpus"
|
||||
monkeypatch.setitem(fake_agents._HANDLER, "Korpus-Soll", lambda p: [])
|
||||
monkeypatch.setitem(fake_agents._HANDLER, "Korpus-Soll-Konsens", lambda p: [])
|
||||
await korpus.bauen(ctx)
|
||||
assert db.one("SELECT status FROM topics WHERE name=?", (topic,))["status"] == "korpus"
|
||||
assert korpus.gate(ctx) == "kein bestätigter Soll-Punkt"
|
||||
|
||||
|
||||
async def test_thema_braucht_zwei_quellen(monkeypatch):
|
||||
topic, (q1, q2), ctx = _seed(art="thema", n_quellen=2)
|
||||
x1 = _kandidat(topic, "X", q1)
|
||||
|
||||
Reference in New Issue
Block a user