import os import sys from pathlib import Path os.environ["CREATOR_FAKE"] = "1" sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) import pytest from backend import config, db, engine, llm # Kleine Fake-Welt → kleine Schwellen config.SOLL_PUNKTE_MIN = 3 config.KAPITEL_SOLL_PUNKTE = 2 config.LUECKEN_RUNDEN_MAX = 1 config.POLL_SEKUNDEN = 0.05 config.DOMAIN_RATE_S = 0 config.DDGS_PAUSE_S = 0 config.QUERIES_JE_LENS = 2 config.VERDICHTUNG_ZIEL = 1 # zwingt den Verdichtungs-Pfad in der Fake-Welt config.TAKT_SEKUNDEN = 0 # kein 3s-Takt in Tests config.SEED_PFLICHT = False # Fake-Welt hat keine echten Startquellen config.QUELLEN_MIN = 1 engine.module_laden() from backend import graph as _graph _graph.get().knoten["gate_korpus"].runden_max = 2 # kleine Fake-Welt @pytest.fixture(autouse=True) def frische_db(): db.reset_for_tests() llm._cooldown_bis = 0.0 llm._breite = config.MAX_PARALLEL_LLM llm._inflight = 0 llm._naechster_start = 0.0 engine._laeufe.clear() yield def topic_anlegen(name="testthema", titel="Testthema"): db.insert("topics", name=name, titel=titel) return name async def lauf_bis_ende(topic: str, budget: int | None = None, timeout=30): import asyncio run_id = engine.lauf_starten(topic, budget) task = engine._laeufe[topic] await asyncio.wait_for(task, timeout) return db.one("SELECT * FROM runs WHERE id=?", run_id)