128 lines
3.7 KiB
Python
Executable File
128 lines
3.7 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Test simple d'initialisation de l'Orchestrator avec des mocks
|
|
pour vérifier que l'erreur AttributeError est corrigée.
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
|
|
# Ajouter le chemin vers geniusia2
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'geniusia2'))
|
|
|
|
print("🔍 Test d'initialisation de l'Orchestrator...")
|
|
print("=" * 60)
|
|
|
|
try:
|
|
# Imports
|
|
print("\n1. Import des modules...")
|
|
from core.logger import Logger
|
|
from core.config import get_config
|
|
print(" ✓ Modules de base importés")
|
|
|
|
# Créer des mocks simples
|
|
print("\n2. Création des mocks...")
|
|
|
|
class MockLearningManager:
|
|
def __init__(self):
|
|
self.embeddings_manager = None
|
|
def get_mode(self):
|
|
return "shadow"
|
|
|
|
class MockVisionUtils:
|
|
pass
|
|
|
|
class MockLLMManager:
|
|
pass
|
|
|
|
class MockWhitelistManager:
|
|
def __init__(self, logger=None):
|
|
pass
|
|
def get_whitelist(self):
|
|
return []
|
|
|
|
class MockInputUtils:
|
|
def __init__(self, logger, config):
|
|
pass
|
|
|
|
print(" ✓ Mocks créés")
|
|
|
|
# Importer Orchestrator
|
|
print("\n3. Import de l'Orchestrator...")
|
|
from core.orchestrator import Orchestrator
|
|
print(" ✓ Orchestrator importé")
|
|
|
|
# Vérifier les méthodes
|
|
print("\n4. Vérification des méthodes de callback...")
|
|
callback_methods = [
|
|
'_on_suggestion_created',
|
|
'_on_suggestion_accepted',
|
|
'_on_suggestion_rejected',
|
|
'_on_suggestion_timeout'
|
|
]
|
|
|
|
all_present = True
|
|
for method in callback_methods:
|
|
if hasattr(Orchestrator, method):
|
|
print(f" ✓ {method}")
|
|
else:
|
|
print(f" ✗ {method} - MANQUANTE!")
|
|
all_present = False
|
|
|
|
if not all_present:
|
|
print("\n❌ Certaines méthodes sont manquantes!")
|
|
sys.exit(1)
|
|
|
|
# Tenter d'initialiser l'Orchestrator
|
|
print("\n5. Initialisation de l'Orchestrator...")
|
|
logger = Logger()
|
|
config = get_config()
|
|
|
|
learning_manager = MockLearningManager()
|
|
vision_utils = MockVisionUtils()
|
|
llm_manager = MockLLMManager()
|
|
whitelist_manager = MockWhitelistManager(logger)
|
|
input_utils = MockInputUtils(logger, config)
|
|
|
|
orchestrator = Orchestrator(
|
|
learning_manager=learning_manager,
|
|
vision_utils=vision_utils,
|
|
llm_manager=llm_manager,
|
|
logger=logger,
|
|
config=config,
|
|
whitelist_manager=whitelist_manager,
|
|
input_utils=input_utils
|
|
)
|
|
|
|
print(" ✓ Orchestrator initialisé avec succès!")
|
|
|
|
# Vérifier que les callbacks sont bien assignés
|
|
print("\n6. Vérification des callbacks assignés...")
|
|
if hasattr(orchestrator, '_on_suggestion_created'):
|
|
print(" ✓ orchestrator._on_suggestion_created existe")
|
|
else:
|
|
print(" ✗ orchestrator._on_suggestion_created n'existe pas!")
|
|
sys.exit(1)
|
|
|
|
print("\n" + "=" * 60)
|
|
print("✅ TOUS LES TESTS PASSENT!")
|
|
print("=" * 60)
|
|
print("\n💡 L'erreur AttributeError est corrigée.")
|
|
print(" Vous pouvez maintenant lancer l'application avec:")
|
|
print(" geniusia2/run.sh")
|
|
|
|
except AttributeError as e:
|
|
print(f"\n❌ AttributeError: {e}")
|
|
print("\n⚠️ L'erreur persiste. Vérifiez le fichier orchestrator.py")
|
|
import traceback
|
|
traceback.print_exc()
|
|
sys.exit(1)
|
|
|
|
except Exception as e:
|
|
print(f"\n⚠️ Autre erreur (peut être normale): {e}")
|
|
print("\n💡 Si l'erreur concerne des dépendances manquantes,")
|
|
print(" c'est normal car nous utilisons des mocks.")
|
|
print(" L'important est qu'il n'y ait pas d'AttributeError.")
|
|
import traceback
|
|
traceback.print_exc()
|