import os, sys, tempfile # _shared lives in web-backend/_shared; add the parent dir so it can be found sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..")) from fastapi.testclient import TestClient def _client(monkeypatch): tmp = tempfile.mkdtemp() from app import db monkeypatch.setattr(db, "DB_PATH", os.path.join(tmp, "lotto.db")) db.init_db() from app.main import app return TestClient(app), db def test_backtest_endpoints(monkeypatch): client, db = _client(monkeypatch) r = client.get("/api/lotto/backtest/track-record") assert r.status_code == 200 assert "by_strategy" in r.json() r2 = client.get("/api/lotto/backtest/calibration?weeks=4") assert r2.status_code == 200 assert isinstance(r2.json().get("history"), list)