Architecture Docker (8 services), FastAPI, TimescaleDB, Redis, Streamlit. Stratégies : scalping, intraday, swing. MLEngine + RegimeDetector (HMM). BacktestEngine + WalkForwardAnalyzer + Optuna optimizer. Routes API complètes dont /optimize async. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
111 lines
2.4 KiB
Python
111 lines
2.4 KiB
Python
"""
|
|
Script pour lancer les tests avec différentes options.
|
|
|
|
Usage:
|
|
python run_tests.py # Tous les tests
|
|
python run_tests.py --unit # Tests unitaires seulement
|
|
python run_tests.py --coverage # Avec coverage
|
|
python run_tests.py --verbose # Mode verbose
|
|
"""
|
|
|
|
import sys
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
|
|
def run_tests(args=None):
|
|
"""
|
|
Lance les tests pytest.
|
|
|
|
Args:
|
|
args: Arguments additionnels pour pytest
|
|
"""
|
|
cmd = ['pytest']
|
|
|
|
if args:
|
|
cmd.extend(args)
|
|
|
|
# Lancer pytest
|
|
result = subprocess.run(cmd, cwd=Path(__file__).parent)
|
|
|
|
return result.returncode
|
|
|
|
|
|
def main():
|
|
"""Point d'entrée principal."""
|
|
import argparse
|
|
|
|
parser = argparse.ArgumentParser(description='Lancer les tests Trading AI Secure')
|
|
|
|
parser.add_argument(
|
|
'--unit',
|
|
action='store_true',
|
|
help='Lancer uniquement les tests unitaires'
|
|
)
|
|
|
|
parser.add_argument(
|
|
'--integration',
|
|
action='store_true',
|
|
help='Lancer uniquement les tests d\'intégration'
|
|
)
|
|
|
|
parser.add_argument(
|
|
'--coverage',
|
|
action='store_true',
|
|
help='Générer rapport de coverage'
|
|
)
|
|
|
|
parser.add_argument(
|
|
'--verbose',
|
|
action='store_true',
|
|
help='Mode verbose'
|
|
)
|
|
|
|
parser.add_argument(
|
|
'--markers',
|
|
type=str,
|
|
help='Filtrer par markers (ex: "slow")'
|
|
)
|
|
|
|
args = parser.parse_args()
|
|
|
|
# Construire arguments pytest
|
|
pytest_args = []
|
|
|
|
if args.unit:
|
|
pytest_args.extend(['-m', 'unit'])
|
|
|
|
if args.integration:
|
|
pytest_args.extend(['-m', 'integration'])
|
|
|
|
if args.coverage:
|
|
pytest_args.extend(['--cov=src', '--cov-report=html', '--cov-report=term'])
|
|
|
|
if args.verbose:
|
|
pytest_args.append('-vv')
|
|
|
|
if args.markers:
|
|
pytest_args.extend(['-m', args.markers])
|
|
|
|
# Lancer tests
|
|
print("=" * 60)
|
|
print("LANCEMENT DES TESTS - TRADING AI SECURE")
|
|
print("=" * 60)
|
|
|
|
exit_code = run_tests(pytest_args)
|
|
|
|
if exit_code == 0:
|
|
print("\n" + "=" * 60)
|
|
print("✅ TOUS LES TESTS SONT PASSÉS")
|
|
print("=" * 60)
|
|
else:
|
|
print("\n" + "=" * 60)
|
|
print("❌ CERTAINS TESTS ONT ÉCHOUÉ")
|
|
print("=" * 60)
|
|
|
|
sys.exit(exit_code)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|