caelum0x b5749ab837 fix: remove hardcoded secrets, add tests, fix PCA bug, pin deps
- Remove hardcoded FRED API key from autoresearch/prepare.py and
  thesis_portfolio_opt/research/experiment.py; load from .env via
  python-dotenv at module level instead
- Add .env.example at root and update MiroFish/.env.example with
  CORS_ORIGINS and FRED_API_KEY documentation
- Replace autoresearch/pyproject.toml: remove unused LLM deps
  (torch, rustbpe, tiktoken), add actual deps (scikit-learn,
  lightgbm, xgboost, fredapi, yfinance, cvxpy)
- Fix PCA backtest bug in autoresearch/train.py: propagate fitted
  PCA/scaler transform through model dict so run_oos_backtest
  replays the same transform on live rows (B10 no longer crashes)
- Fix MiroFish CORS wildcard: read allowed origins from CORS_ORIGINS
  env var, default to localhost dev origins
- Add MiroFish test suite (36 tests): config validation, file
  parser, text processor, task manager, API health/blueprints
- Pin upper bounds on thesis_portfolio_opt/requirements.txt

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 20:16:45 +03:00

33 lines
1.1 KiB
Python

"""Tests for Flask app creation and health endpoint."""
import pytest
class TestAppFactory:
def test_app_creates(self, app):
assert app is not None
assert app.config['TESTING'] is True
def test_health_endpoint(self, client):
response = client.get('/health')
assert response.status_code == 200
data = response.get_json()
assert data['status'] == 'ok'
assert data['service'] == 'MiroFish Backend'
def test_cors_headers(self, client):
response = client.options('/api/graph/project/list', headers={
'Origin': 'http://localhost:3000',
'Access-Control-Request-Method': 'GET',
})
# CORS should allow configured origins
assert response.status_code in (200, 204)
def test_blueprints_registered(self, app):
rules = [rule.rule for rule in app.url_map.iter_rules()]
assert '/health' in rules
# Check that blueprint prefixes are registered
assert any(r.startswith('/api/graph') for r in rules)
assert any(r.startswith('/api/simulation') for r in rules)
assert any(r.startswith('/api/report') for r in rules)