178 lines
6.1 KiB
Python
178 lines
6.1 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test d'intégration - EnrichedScreenCapture dans Orchestrator
|
|
Vérifie que l'intégration est correcte.
|
|
"""
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Ajouter le répertoire parent au path
|
|
sys.path.insert(0, str(Path(__file__).parent))
|
|
|
|
print("="*70)
|
|
print("TEST D'INTÉGRATION - EnrichedScreenCapture dans Orchestrator")
|
|
print("="*70)
|
|
|
|
# Test 1: Vérifier que la configuration est correcte
|
|
print("\n1. Test Configuration...")
|
|
try:
|
|
from geniusia2.core.config import get_config
|
|
config = get_config()
|
|
|
|
assert "ui_detection" in config, "ui_detection manquant dans config"
|
|
assert "multimodal_embedding" in config, "multimodal_embedding manquant dans config"
|
|
assert "enhanced_matcher" in config, "enhanced_matcher manquant dans config"
|
|
|
|
print(f" ✓ Configuration UI Detection:")
|
|
print(f" - Mode: {config['ui_detection']['mode']}")
|
|
print(f" - Enabled: {config['ui_detection']['enabled']}")
|
|
|
|
print(f" ✓ Configuration Multimodal Embedding:")
|
|
print(f" - Enabled: {config['multimodal_embedding']['enabled']}")
|
|
print(f" - Weights: {config['multimodal_embedding']['weights']}")
|
|
|
|
print(f" ✓ Configuration Enhanced Matcher:")
|
|
print(f" - Screen weight: {config['enhanced_matcher']['screen_weight']}")
|
|
print(f" - Elements weight: {config['enhanced_matcher']['elements_weight']}")
|
|
|
|
print(" ✅ Configuration OK")
|
|
except Exception as e:
|
|
print(f" ❌ Erreur configuration: {e}")
|
|
sys.exit(1)
|
|
|
|
# Test 2: Vérifier que les imports fonctionnent
|
|
print("\n2. Test Imports...")
|
|
try:
|
|
from geniusia2.core.enriched_screen_capture import EnrichedScreenCapture
|
|
print(" ✓ EnrichedScreenCapture importé")
|
|
|
|
from geniusia2.core.multimodal_embedding_manager import MultiModalEmbeddingManager
|
|
print(" ✓ MultiModalEmbeddingManager importé")
|
|
|
|
from geniusia2.core.enhanced_workflow_matcher import EnhancedWorkflowMatcher
|
|
print(" ✓ EnhancedWorkflowMatcher importé")
|
|
|
|
from geniusia2.core.ui_element_models import EnrichedScreenState, UIElement
|
|
print(" ✓ UI Element Models importés")
|
|
|
|
print(" ✅ Imports OK")
|
|
except Exception as e:
|
|
print(f" ❌ Erreur imports: {e}")
|
|
sys.exit(1)
|
|
|
|
# Test 3: Vérifier que EnrichedScreenCapture peut être instancié
|
|
print("\n3. Test Instanciation EnrichedScreenCapture...")
|
|
try:
|
|
from geniusia2.core.logger import Logger
|
|
|
|
logger = Logger(log_dir="test_logs")
|
|
|
|
# Test mode light
|
|
capture_light = EnrichedScreenCapture(
|
|
logger=logger,
|
|
data_dir="test_data",
|
|
mode="light"
|
|
)
|
|
print(f" ✓ Mode light: {capture_light.get_mode()}")
|
|
|
|
# Test mode enriched
|
|
capture_enriched = EnrichedScreenCapture(
|
|
logger=logger,
|
|
data_dir="test_data",
|
|
mode="enriched"
|
|
)
|
|
print(f" ✓ Mode enriched: {capture_enriched.get_mode()}")
|
|
|
|
# Test mode complete
|
|
capture_complete = EnrichedScreenCapture(
|
|
logger=logger,
|
|
data_dir="test_data",
|
|
mode="complete"
|
|
)
|
|
print(f" ✓ Mode complete: {capture_complete.get_mode()}")
|
|
|
|
print(" ✅ Instanciation OK")
|
|
except Exception as e:
|
|
print(f" ❌ Erreur instanciation: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
sys.exit(1)
|
|
|
|
# Test 4: Vérifier la structure de l'Orchestrator (sans l'instancier)
|
|
print("\n4. Test Structure Orchestrator...")
|
|
try:
|
|
import inspect
|
|
# On ne peut pas importer Orchestrator à cause des dépendances torch
|
|
# Mais on peut vérifier que le fichier est syntaxiquement correct
|
|
|
|
with open("geniusia2/core/orchestrator.py", "r") as f:
|
|
content = f.read()
|
|
|
|
# Vérifier que les imports sont présents
|
|
assert "from .enriched_screen_capture import EnrichedScreenCapture" in content
|
|
print(" ✓ Import EnrichedScreenCapture présent")
|
|
|
|
# Vérifier que l'initialisation est présente
|
|
assert "self.enriched_capture = EnrichedScreenCapture(" in content
|
|
print(" ✓ Initialisation enriched_capture présente")
|
|
|
|
# Vérifier que capture_and_enrich est utilisé
|
|
assert "self.enriched_capture.capture_and_enrich(" in content
|
|
print(" ✓ Utilisation de capture_and_enrich présente")
|
|
|
|
print(" ✅ Structure Orchestrator OK")
|
|
except Exception as e:
|
|
print(f" ❌ Erreur structure: {e}")
|
|
sys.exit(1)
|
|
|
|
# Test 5: Vérifier que la configuration est chargée correctement
|
|
print("\n5. Test Chargement Configuration...")
|
|
try:
|
|
config = get_config()
|
|
|
|
# Vérifier les valeurs par défaut
|
|
assert config["ui_detection"]["mode"] == "light"
|
|
print(" ✓ Mode par défaut: light")
|
|
|
|
assert config["ui_detection"]["enabled"] == True
|
|
print(" ✓ UI Detection enabled par défaut")
|
|
|
|
assert config["multimodal_embedding"]["enabled"] == False
|
|
print(" ✓ Multimodal embedding disabled par défaut (activé en mode complete)")
|
|
|
|
assert config["enhanced_matcher"]["enabled"] == True
|
|
print(" ✓ Enhanced matcher enabled par défaut")
|
|
|
|
print(" ✅ Configuration chargée correctement")
|
|
except Exception as e:
|
|
print(f" ❌ Erreur chargement config: {e}")
|
|
sys.exit(1)
|
|
|
|
# Nettoyage
|
|
print("\n6. Nettoyage...")
|
|
import shutil
|
|
if Path("test_data").exists():
|
|
shutil.rmtree("test_data")
|
|
if Path("test_logs").exists():
|
|
shutil.rmtree("test_logs")
|
|
print(" ✓ Nettoyage terminé")
|
|
|
|
# Résumé
|
|
print("\n" + "="*70)
|
|
print("✅ TOUS LES TESTS D'INTÉGRATION RÉUSSIS!")
|
|
print("="*70)
|
|
print("\nRésumé:")
|
|
print(" ✓ Configuration ajoutée (ui_detection, multimodal_embedding, enhanced_matcher)")
|
|
print(" ✓ EnrichedScreenCapture importé dans orchestrator.py")
|
|
print(" ✓ enriched_capture initialisé dans Orchestrator.__init__")
|
|
print(" ✓ capture_and_enrich utilisé dans find_matching_workflows_enhanced")
|
|
print(" ✓ Tous les modes fonctionnent (light, enriched, complete)")
|
|
print("\n🎉 L'intégration est complète et fonctionnelle!")
|
|
print("\nProchaines étapes:")
|
|
print(" 1. Tester avec l'application réelle")
|
|
print(" 2. Activer le mode 'enriched' ou 'complete' dans config.py si besoin")
|
|
print(" 3. Monitorer les logs pour vérifier le bon fonctionnement")
|
|
|
|
sys.exit(0)
|