This commit is contained in:
team3
2026-07-24 11:23:18 +02:00
parent cb68cd671b
commit 1b054497ed
49 changed files with 935 additions and 408 deletions

View File

@@ -119,6 +119,7 @@ async def test_gate_guide_neuschreiben_bei_kaputten_markern():
assert writer_tasks and writer_tasks[0]["payload"]["neu"] is True
# Neuschreiben resettet den Fix-Cap und ersetzt den Text
await guide.writer({"run_id": run_id, "topic": topic, "runde": 2,
"knoten": "writer",
"item": f"r2:baustein:{bid}",
"payload": db.j({"baustein_id": bid, "neu": True})})
sec = db.one("SELECT * FROM sections WHERE baustein_id=?", bid)
@@ -201,8 +202,9 @@ async def test_vorwaerts_ignoriert_verlinkte_erwaehnung():
if b["art"] == "vorwaerts"]
async def test_gate_verwirft_soll_lose_atome():
from backend import inventar
async def test_gate_verwirft_soll_lose_atome(monkeypatch):
from backend import config, inventar
monkeypatch.setattr(config, "BEIFANG_MAX_QUOTE", 1.0) # Stop hier nicht Testziel
topic = topic_anlegen()
run_id = db.insert("runs", topic=topic, status="running")
geprueft = db.insert("atome", topic=topic, titel="Beifang", status="aktiv",
@@ -210,7 +212,8 @@ async def test_gate_verwirft_soll_lose_atome():
frisch = db.insert("atome", topic=topic, titel="Frisch", status="aktiv",
soll_geprueft=0)
await inventar.gate({"run_id": run_id, "topic": topic, "runde": 1,
"item": "runde:1", "payload": "{}"})
"knoten": "gate_inventar", "item": "runde:1",
"payload": "{}"})
assert db.one("SELECT status FROM atome WHERE id=?", geprueft)[
"status"] == "verworfen"
assert db.one("SELECT status FROM atome WHERE id=?", frisch)[
@@ -280,3 +283,66 @@ async def test_budget_stoppt_lauf():
import pytest
with pytest.raises(BudgetErschoepft):
budget_pruefen(run["id"])
async def test_stop_seed_fehlt(monkeypatch):
"""Vollständigkeit ist DAS Kernziel: ohne nützlich geladene Startquelle
PAUSE statt Mini-Guide (Lektion 103/106)."""
import pytest
from backend import config, korpus, llm
monkeypatch.setattr(config, "SEED_PFLICHT", True)
monkeypatch.setattr(config, "QUELLEN_MIN", 1)
topic = topic_anlegen()
run_id = db.insert("runs", topic=topic, status="running")
db.insert("quellen", topic=topic, url="https://a.de", url_norm="a",
backend="ddgs", status="geladen", zweck="korpus")
for i in range(3):
db.insert("soll", topic=topic, punkt=f"P{i}", status="bestaetigt")
db.insert("tasks", run_id=run_id, topic=topic, knoten="gate_korpus",
item="runde:1", runde=1, status="fertig",
ergebnis=db.j({"bestaetigt": 3}))
with pytest.raises(llm.LaufPause, match="seed_fehlt"):
await korpus.gate({"run_id": run_id, "topic": topic, "runde": 2,
"knoten": "gate_korpus", "item": "runde:2",
"payload": "{}"})
async def test_stop_zu_wenige_quellen(monkeypatch):
import pytest
from backend import config, korpus, llm
monkeypatch.setattr(config, "SEED_PFLICHT", False)
monkeypatch.setattr(config, "QUELLEN_MIN", 5)
topic = topic_anlegen()
run_id = db.insert("runs", topic=topic, status="running")
db.insert("quellen", topic=topic, url="https://a.de", url_norm="a",
backend="ddgs", status="geladen", zweck="korpus")
for i in range(3):
db.insert("soll", topic=topic, punkt=f"P{i}", status="bestaetigt")
db.insert("tasks", run_id=run_id, topic=topic, knoten="gate_korpus",
item="runde:1", runde=1, status="fertig",
ergebnis=db.j({"bestaetigt": 3}))
with pytest.raises(llm.LaufPause, match="quellen"):
await korpus.gate({"run_id": run_id, "topic": topic, "runde": 2,
"knoten": "gate_korpus", "item": "runde:2",
"payload": "{}"})
async def test_stop_beifang_quote():
""">50 % der Atome als Beifang verworfen → Soll zu eng → PAUSE."""
import pytest
from backend import inventar, llm
topic = topic_anlegen()
run_id = db.insert("runs", topic=topic, status="running")
s = db.insert("soll", topic=topic, punkt="P", status="bestaetigt",
belege=db.j([]))
behalten = db.insert("atome", topic=topic, titel="Gut", status="aktiv",
soll_id=s, soll_geprueft=1)
for i in range(2):
db.insert("atome", topic=topic, titel=f"Beifang{i}", status="aktiv",
soll_geprueft=1)
with pytest.raises(llm.LaufPause, match="beifang"):
await inventar.gate({"run_id": run_id, "topic": topic, "runde": 1,
"knoten": "gate_inventar", "item": "runde:1",
"payload": "{}"})
assert db.one("SELECT status FROM atome WHERE id=?", behalten)[
"status"] == "aktiv"