[verified] Add API tests for /api/v1/learning/factors + configurable history dir

Closes reviewer suggestion (deleg_5dd358e3): adds coverage for the factor
readiness endpoint (n_points / learnable / last_value / ordering) and the
min_points 400 validation. FACTOR_HISTORY_DIR is now configurable via app
config so tests (and deploy) can point the history store at a chosen path
instead of a hardcoded data dir. 236 tests pass.
This commit is contained in:
Kunthawat Greethong
2026-08-27 07:37:01 +07:00
parent d87a1ada39
commit b362cc35bf
2 changed files with 28 additions and 1 deletions

View File

@@ -790,7 +790,9 @@ def create_app(config: dict[str, Any] | None = None) -> Flask:
"""
from app import factors as factors_mod
from app.factor_history import FactorHistory
fh = FactorHistory(Path(__file__).resolve().parents[1] / "data" / "factor_history")
hist_dir = app.config.get("FACTOR_HISTORY_DIR") or (
Path(__file__).resolve().parents[1] / "data" / "factor_history")
fh = FactorHistory(hist_dir)
try:
min_points = max(int(request.args.get("min_points", "12")), 0)
except (TypeError, ValueError):