49 lines
1.2 KiB
Python
49 lines
1.2 KiB
Python
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.RECHERCHE_RUNDEN_MAX = 2
|
|
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
|
|
|
|
engine.module_laden()
|
|
|
|
|
|
@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)
|