feat(lotto): backtest API 라우터 + main 등록
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
23
lotto/tests/test_backtest_api.py
Normal file
23
lotto/tests/test_backtest_api.py
Normal file
@@ -0,0 +1,23 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user