92 lines
		
	
	
	
		
			2.9 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			92 lines
		
	
	
	
		
			2.9 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| #!/usr/bin/env python3
 | |
| """
 | |
| Script de test pour les améliorations du scraper agenda du libre
 | |
| Démontre les nouvelles fonctionnalités : cache JSON, limitation d'événements, mode dry-run
 | |
| """
 | |
| 
 | |
| import subprocess
 | |
| import sys
 | |
| import os
 | |
| 
 | |
| def run_test(test_name, command):
 | |
|     """Exécute un test et affiche les résultats"""
 | |
|     print(f"\n{'='*60}")
 | |
|     print(f"TEST: {test_name}")
 | |
|     print(f"{'='*60}")
 | |
|     print(f"Commande: {' '.join(command)}")
 | |
|     print("-" * 60)
 | |
|     
 | |
|     try:
 | |
|         result = subprocess.run(command, capture_output=True, text=True, timeout=120)
 | |
|         print("STDOUT:")
 | |
|         print(result.stdout)
 | |
|         if result.stderr:
 | |
|             print("STDERR:")
 | |
|             print(result.stderr)
 | |
|         print(f"Code de retour: {result.returncode}")
 | |
|         return result.returncode == 0
 | |
|     except subprocess.TimeoutExpired:
 | |
|         print("TIMEOUT: Le test a pris trop de temps")
 | |
|         return False
 | |
|     except Exception as e:
 | |
|         print(f"ERREUR: {e}")
 | |
|         return False
 | |
| 
 | |
| def main():
 | |
|     """Exécute une série de tests pour démontrer les améliorations"""
 | |
|     print("🧪 Tests des améliorations du scraper agenda du libre")
 | |
|     print("=" * 60)
 | |
|     
 | |
|     # Vérifier que le script existe
 | |
|     script_path = "agendadulibre.py"
 | |
|     if not os.path.exists(script_path):
 | |
|         print(f"❌ Erreur: Le script {script_path} n'existe pas")
 | |
|         sys.exit(1)
 | |
|     
 | |
|     tests = [
 | |
|         {
 | |
|             "name": "Test 1: Mode dry-run par défaut (limite 5 événements)",
 | |
|             "command": [sys.executable, script_path, "--max-events", "5", "--verbose"]
 | |
|         },
 | |
|         {
 | |
|             "name": "Test 2: Mode dry-run avec cache (limite 3 événements)",
 | |
|             "command": [sys.executable, script_path, "--max-events", "3", "--verbose"]
 | |
|         },
 | |
|         {
 | |
|             "name": "Test 3: Mode réel (--no-dry-run) avec limite 2 événements",
 | |
|             "command": [sys.executable, script_path, "--no-dry-run", "--max-events", "2", "--verbose"]
 | |
|         },
 | |
|         {
 | |
|             "name": "Test 4: Force refresh avec dry-run",
 | |
|             "command": [sys.executable, script_path, "--force-refresh", "--max-events", "3", "--verbose"]
 | |
|         }
 | |
|     ]
 | |
|     
 | |
|     results = []
 | |
|     for test in tests:
 | |
|         success = run_test(test["name"], test["command"])
 | |
|         results.append((test["name"], success))
 | |
|     
 | |
|     # Résumé des tests
 | |
|     print(f"\n{'='*60}")
 | |
|     print("RÉSUMÉ DES TESTS")
 | |
|     print(f"{'='*60}")
 | |
|     
 | |
|     passed = 0
 | |
|     for name, success in results:
 | |
|         status = "✅ PASSÉ" if success else "❌ ÉCHOUÉ"
 | |
|         print(f"{status}: {name}")
 | |
|         if success:
 | |
|             passed += 1
 | |
|     
 | |
|     print(f"\nRésultat: {passed}/{len(results)} tests réussis")
 | |
|     
 | |
|     if passed == len(results):
 | |
|         print("🎉 Tous les tests sont passés avec succès !")
 | |
|         return 0
 | |
|     else:
 | |
|         print("⚠️ Certains tests ont échoué")
 | |
|         return 1
 | |
| 
 | |
| if __name__ == "__main__":
 | |
|     sys.exit(main())
 | 
