34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "backend"))
|
|
|
|
import db # noqa: E402
|
|
import embedding # noqa: E402
|
|
import korpus # noqa: E402
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def fake_welt(tmp_path, monkeypatch):
|
|
"""Jeder Test: frische In-Memory-DB, Fake-Agenten, Korpus/Topics in tmp.
|
|
Embedding fest auf Jaccard-Fallback — kein Modell-Download, deterministisch."""
|
|
monkeypatch.setenv("CREATOR_FAKE_AGENTS", "1")
|
|
monkeypatch.setattr(embedding, "_geladen", True)
|
|
monkeypatch.setattr(embedding, "_modell", None)
|
|
monkeypatch.setattr(korpus, "KORPUS_DIR", tmp_path / "korpus")
|
|
monkeypatch.setattr(korpus, "TOPICS_DIR", tmp_path / "topics")
|
|
db.on_change = None
|
|
db.reset_for_tests(":memory:")
|
|
yield tmp_path
|
|
|
|
|
|
def topic_anlegen(name="fake-thema", art="thema"):
|
|
db.insert("topics", name=name, titel=name, art=art, provider="minimax")
|
|
return name
|
|
|
|
|
|
def run_anlegen(topic, budget=0):
|
|
return db.insert("runs", topic=topic, status="running", budget_tokens=budget)
|