v1.0 - Version stable: multi-PC, détection UI-DETR-1, 3 modes exécution
- Frontend v4 accessible sur réseau local (192.168.1.40) - Ports ouverts: 3002 (frontend), 5001 (backend), 5004 (dashboard) - Ollama GPU fonctionnel - Self-healing interactif - Dashboard confiance Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
209
test_actions_import_simple.py
Normal file
209
test_actions_import_simple.py
Normal file
@@ -0,0 +1,209 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test Simple - Import des Actions VWB
|
||||
|
||||
Auteur : Dom, Alice, Kiro - 10 janvier 2026
|
||||
|
||||
Test simple pour vérifier que toutes les actions peuvent être importées.
|
||||
"""
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Ajouter le répertoire racine au PYTHONPATH
|
||||
project_root = Path(__file__).parent
|
||||
sys.path.insert(0, str(project_root))
|
||||
|
||||
def test_imports():
|
||||
"""Test des imports des actions."""
|
||||
print("🧪 Test des imports des actions VWB...")
|
||||
|
||||
try:
|
||||
# Test import du module base
|
||||
from visual_workflow_builder.backend.actions.base_action import BaseVWBAction, VWBActionResult, VWBActionStatus
|
||||
print("✅ Import base_action réussi")
|
||||
|
||||
# Test import des contrats
|
||||
from visual_workflow_builder.backend.contracts.error import VWBErrorType, VWBErrorSeverity, create_vwb_error
|
||||
from visual_workflow_builder.backend.contracts.evidence import VWBEvidence, VWBEvidenceType
|
||||
from visual_workflow_builder.backend.contracts.visual_anchor import VWBVisualAnchor
|
||||
print("✅ Import contrats réussi")
|
||||
|
||||
# Test import des actions individuelles
|
||||
from visual_workflow_builder.backend.actions.vision_ui.click_anchor import VWBClickAnchorAction
|
||||
print("✅ Import VWBClickAnchorAction réussi")
|
||||
|
||||
from visual_workflow_builder.backend.actions.vision_ui.type_text import VWBTypeTextAction
|
||||
print("✅ Import VWBTypeTextAction réussi")
|
||||
|
||||
from visual_workflow_builder.backend.actions.vision_ui.wait_for_anchor import VWBWaitForAnchorAction
|
||||
print("✅ Import VWBWaitForAnchorAction réussi")
|
||||
|
||||
from visual_workflow_builder.backend.actions.vision_ui.focus_anchor import VWBFocusAnchorAction
|
||||
print("✅ Import VWBFocusAnchorAction réussi")
|
||||
|
||||
from visual_workflow_builder.backend.actions.vision_ui.type_secret import VWBTypeSecretAction
|
||||
print("✅ Import VWBTypeSecretAction réussi")
|
||||
|
||||
from visual_workflow_builder.backend.actions.vision_ui.scroll_to_anchor import VWBScrollToAnchorAction
|
||||
print("✅ Import VWBScrollToAnchorAction réussi")
|
||||
|
||||
from visual_workflow_builder.backend.actions.vision_ui.extract_text import VWBExtractTextAction
|
||||
print("✅ Import VWBExtractTextAction réussi")
|
||||
|
||||
# Test import du module complet
|
||||
from visual_workflow_builder.backend.actions import (
|
||||
BaseVWBAction, VWBActionResult, VWBActionStatus,
|
||||
VWBClickAnchorAction, VWBTypeTextAction, VWBWaitForAnchorAction,
|
||||
VWBFocusAnchorAction, VWBTypeSecretAction, VWBScrollToAnchorAction,
|
||||
VWBExtractTextAction
|
||||
)
|
||||
print("✅ Import module actions complet réussi")
|
||||
|
||||
return True
|
||||
|
||||
except ImportError as e:
|
||||
print(f"❌ Erreur d'import: {e}")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f"❌ Erreur inattendue: {e}")
|
||||
return False
|
||||
|
||||
def test_action_creation():
|
||||
"""Test de création d'instances d'actions."""
|
||||
print("\n🔧 Test de création d'instances d'actions...")
|
||||
|
||||
try:
|
||||
from visual_workflow_builder.backend.actions.vision_ui.focus_anchor import VWBFocusAnchorAction
|
||||
from visual_workflow_builder.backend.contracts.visual_anchor import VWBVisualAnchor, VWBVisualAnchorType
|
||||
from datetime import datetime
|
||||
|
||||
# Créer une ancre visuelle de test
|
||||
test_anchor = VWBVisualAnchor(
|
||||
anchor_id="test_anchor",
|
||||
anchor_type=VWBVisualAnchorType.IMAGE_TEMPLATE,
|
||||
name="Bouton Test",
|
||||
description="Bouton de test pour validation",
|
||||
search_criteria={},
|
||||
created_by="test_user",
|
||||
created_at=datetime.now(),
|
||||
reference_image_base64="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==",
|
||||
bounding_box={"x": 100, "y": 200, "width": 50, "height": 30},
|
||||
confidence_threshold=0.8
|
||||
)
|
||||
|
||||
# Créer une action de test
|
||||
test_action = VWBFocusAnchorAction(
|
||||
action_id="test_focus",
|
||||
parameters={
|
||||
"visual_anchor": test_anchor,
|
||||
"focus_method": "click",
|
||||
"confidence_threshold": 0.9
|
||||
},
|
||||
screen_capturer=None # Pas de ScreenCapturer pour ce test
|
||||
)
|
||||
|
||||
print("✅ Création VWBFocusAnchorAction réussie")
|
||||
|
||||
# Vérifier les métadonnées
|
||||
metadata = test_action.get_action_metadata()
|
||||
assert metadata["id"] == "focus_anchor"
|
||||
assert metadata["name"] == "Donner le Focus à un Élément"
|
||||
assert metadata["category"] == "vision_ui"
|
||||
|
||||
print("✅ Métadonnées action validées")
|
||||
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Erreur création action: {e}")
|
||||
return False
|
||||
|
||||
def test_catalog_routes():
|
||||
"""Test des routes du catalogue."""
|
||||
print("\n🌐 Test des routes du catalogue...")
|
||||
|
||||
try:
|
||||
from visual_workflow_builder.backend.catalog_routes import create_action_from_config
|
||||
from datetime import datetime
|
||||
|
||||
# Test de création d'action via config
|
||||
config = {
|
||||
"type": "focus_anchor",
|
||||
"action_id": "test_config",
|
||||
"parameters": {
|
||||
"visual_anchor": {
|
||||
"anchor_id": "test_anchor",
|
||||
"anchor_type": "image_template",
|
||||
"name": "Bouton Test",
|
||||
"description": "Bouton de test pour validation",
|
||||
"search_criteria": {},
|
||||
"created_by": "test_user",
|
||||
"created_at": datetime.now().isoformat(),
|
||||
"reference_image_base64": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==",
|
||||
"bounding_box": {"x": 100, "y": 200, "width": 50, "height": 30},
|
||||
"confidence_threshold": 0.8
|
||||
},
|
||||
"focus_method": "click"
|
||||
}
|
||||
}
|
||||
|
||||
action = create_action_from_config(config)
|
||||
if action:
|
||||
print("✅ Création action via config réussie")
|
||||
else:
|
||||
print("⚠️ Création action via config échouée (normal si ScreenCapturer indisponible)")
|
||||
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Erreur test routes catalogue: {e}")
|
||||
return False
|
||||
|
||||
def main():
|
||||
"""Fonction principale."""
|
||||
print("🎯 TEST SIMPLE - IMPORT ACTIONS VWB")
|
||||
print("=" * 40)
|
||||
|
||||
tests = [
|
||||
("Import des modules", test_imports),
|
||||
("Création d'instances", test_action_creation),
|
||||
("Routes catalogue", test_catalog_routes)
|
||||
]
|
||||
|
||||
results = {}
|
||||
|
||||
for test_name, test_func in tests:
|
||||
try:
|
||||
print(f"\n📋 {test_name}...")
|
||||
success = test_func()
|
||||
results[test_name] = "✅ RÉUSSI" if success else "❌ ÉCHEC"
|
||||
except Exception as e:
|
||||
results[test_name] = f"❌ ERREUR: {e}"
|
||||
|
||||
# Résumé
|
||||
print(f"\n📊 RÉSUMÉ DES TESTS")
|
||||
print("=" * 40)
|
||||
|
||||
success_count = 0
|
||||
for test_name, result in results.items():
|
||||
print(f"{result} {test_name}")
|
||||
if result.startswith("✅"):
|
||||
success_count += 1
|
||||
|
||||
total_tests = len(tests)
|
||||
success_rate = (success_count / total_tests) * 100
|
||||
|
||||
print("=" * 40)
|
||||
print(f"📈 TAUX DE RÉUSSITE: {success_count}/{total_tests} ({success_rate:.1f}%)")
|
||||
|
||||
if success_rate >= 80:
|
||||
print("🎉 IMPORTS ACTIONS VWB VALIDÉS!")
|
||||
return True
|
||||
else:
|
||||
print("⚠️ Problèmes d'import détectés")
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
success = main()
|
||||
sys.exit(0 if success else 1)
|
||||
Reference in New Issue
Block a user