73 lines
1.6 KiB
Python
73 lines
1.6 KiB
Python
"""
|
|
Script pour exécuter tous les tests du backend.
|
|
"""
|
|
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
def run_command(cmd: str, description: str) -> bool:
|
|
"""
|
|
Exécute une commande shell et retourne le succès.
|
|
|
|
Args:
|
|
cmd: Commande à exécuter
|
|
description: Description de la commande
|
|
|
|
Returns:
|
|
True si la commande a réussi, False sinon
|
|
"""
|
|
print(f"\n🔍 {description}")
|
|
print("=" * 60)
|
|
|
|
try:
|
|
result = subprocess.run(
|
|
cmd,
|
|
shell=True,
|
|
check=True,
|
|
capture_output=False
|
|
)
|
|
print(f"✅ {description} réussi !")
|
|
return True
|
|
except subprocess.CalledProcessError as e:
|
|
print(f"❌ {description} échoué avec le code {e.returncode}")
|
|
return False
|
|
|
|
|
|
def main():
|
|
"""Fonction principale."""
|
|
print("🧪 Exécution des tests du backend...")
|
|
print("=" * 60)
|
|
|
|
all_passed = True
|
|
|
|
# Tests unitaires
|
|
all_passed &= run_command(
|
|
"pytest tests/ -v --tb=short",
|
|
"Tests unitaires"
|
|
)
|
|
|
|
# Linting
|
|
all_passed &= run_command(
|
|
"flake8 app/ --max-line-length=100",
|
|
"Linting avec flake8"
|
|
)
|
|
|
|
# Formatting
|
|
all_passed &= run_command(
|
|
"black --check app/",
|
|
"Vérification du formatage avec black"
|
|
)
|
|
|
|
print("\n" + "=" * 60)
|
|
if all_passed:
|
|
print("✅ Tous les tests et validations ont réussi !")
|
|
return 0
|
|
else:
|
|
print("❌ Certains tests ou validations ont échoué.")
|
|
return 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|