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:
199
visual_workflow_builder/quick_api_test.py
Normal file
199
visual_workflow_builder/quick_api_test.py
Normal file
@@ -0,0 +1,199 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test rapide des API principales du VWB
|
||||
Auteur : Dom, Alice, Kiro - 8 janvier 2026
|
||||
"""
|
||||
|
||||
import requests
|
||||
import json
|
||||
import sys
|
||||
import os
|
||||
|
||||
# Configuration
|
||||
BACKEND_PORT = 5002
|
||||
BASE_URL = f'http://localhost:{BACKEND_PORT}'
|
||||
|
||||
def test_health():
|
||||
"""Test de santé du serveur backend"""
|
||||
try:
|
||||
response = requests.get(f'{BASE_URL}/health', timeout=5)
|
||||
print(f"Health: {response.status_code} - {response.json()}")
|
||||
return response.status_code == 200
|
||||
except requests.exceptions.ConnectionError:
|
||||
print("❌ Impossible de se connecter au serveur backend")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f"❌ Erreur health check: {e}")
|
||||
return False
|
||||
|
||||
def test_screen_capture():
|
||||
"""Test capture d'écran réelle"""
|
||||
try:
|
||||
response = requests.post(f'{BASE_URL}/api/screen-capture/', json={}, timeout=10)
|
||||
print(f"Screen Capture: {response.status_code}")
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
print(f" - Dimensions: {data.get('width', 0)}x{data.get('height', 0)}")
|
||||
print(f" - Image: {'✅' if 'image' in data else '❌'}")
|
||||
print(f" - Format: {data.get('format', 'N/A')}")
|
||||
return response.status_code == 200
|
||||
except Exception as e:
|
||||
print(f"❌ Erreur capture d'écran: {e}")
|
||||
return False
|
||||
|
||||
def test_element_detection():
|
||||
"""Test détection d'éléments UI réels"""
|
||||
try:
|
||||
# D'abord capturer l'écran
|
||||
capture_response = requests.post(f'{BASE_URL}/api/screen-capture/', json={}, timeout=10)
|
||||
if capture_response.status_code != 200:
|
||||
print("❌ Impossible de capturer l'écran pour la détection")
|
||||
return False
|
||||
|
||||
# Ensuite détecter les éléments
|
||||
response = requests.post(f'{BASE_URL}/api/screen-capture/detect-elements',
|
||||
json=capture_response.json(), timeout=15)
|
||||
print(f"Element Detection: {response.status_code}")
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
print(f" - Éléments détectés: {data.get('count', 0)}")
|
||||
print(f" - Types: {', '.join(data.get('types', []))}")
|
||||
return response.status_code == 200
|
||||
except Exception as e:
|
||||
print(f"❌ Erreur détection d'éléments: {e}")
|
||||
return False
|
||||
|
||||
def test_workflow_crud():
|
||||
"""Test CRUD workflows avec données réelles"""
|
||||
try:
|
||||
# Test CREATE
|
||||
workflow = {
|
||||
"name": "Test Workflow Réel",
|
||||
"description": "Test de workflow avec fonctionnalité réelle",
|
||||
"nodes": [
|
||||
{
|
||||
"id": "node1",
|
||||
"type": "capture",
|
||||
"position": {"x": 100, "y": 100},
|
||||
"data": {"label": "Capture d'écran"}
|
||||
}
|
||||
],
|
||||
"edges": [],
|
||||
"variables": [
|
||||
{"name": "test_var", "value": "test_value", "type": "string"}
|
||||
]
|
||||
}
|
||||
|
||||
response = requests.post(f'{BASE_URL}/api/workflows/', json=workflow, timeout=10)
|
||||
print(f"Workflow CREATE: {response.status_code}")
|
||||
|
||||
if response.status_code == 201:
|
||||
workflow_data = response.json()
|
||||
workflow_id = workflow_data.get('id')
|
||||
print(f" - ID créé: {workflow_id}")
|
||||
|
||||
# Test READ
|
||||
response = requests.get(f'{BASE_URL}/api/workflows/{workflow_id}', timeout=5)
|
||||
print(f"Workflow READ: {response.status_code}")
|
||||
if response.status_code == 200:
|
||||
read_data = response.json()
|
||||
print(f" - Nom lu: {read_data.get('name')}")
|
||||
|
||||
# Test UPDATE
|
||||
workflow['description'] = "Description mise à jour"
|
||||
response = requests.put(f'{BASE_URL}/api/workflows/{workflow_id}',
|
||||
json=workflow, timeout=10)
|
||||
print(f"Workflow UPDATE: {response.status_code}")
|
||||
|
||||
# Test DELETE
|
||||
response = requests.delete(f'{BASE_URL}/api/workflows/{workflow_id}', timeout=5)
|
||||
print(f"Workflow DELETE: {response.status_code}")
|
||||
|
||||
return True
|
||||
else:
|
||||
print(f"❌ Échec création workflow: {response.text}")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Erreur CRUD workflow: {e}")
|
||||
return False
|
||||
|
||||
def test_backend_status():
|
||||
"""Vérification complète du statut backend"""
|
||||
try:
|
||||
# Test des endpoints critiques
|
||||
endpoints = [
|
||||
'/health',
|
||||
'/api/status',
|
||||
'/api/workflows/',
|
||||
]
|
||||
|
||||
results = {}
|
||||
for endpoint in endpoints:
|
||||
try:
|
||||
response = requests.get(f'{BASE_URL}{endpoint}', timeout=5)
|
||||
results[endpoint] = response.status_code
|
||||
except:
|
||||
results[endpoint] = 'ERREUR'
|
||||
|
||||
print("📊 Statut des endpoints:")
|
||||
for endpoint, status in results.items():
|
||||
status_icon = "✅" if status == 200 else "❌"
|
||||
print(f" {status_icon} {endpoint}: {status}")
|
||||
|
||||
return all(status == 200 for status in results.values() if status != 'ERREUR')
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Erreur vérification backend: {e}")
|
||||
return False
|
||||
|
||||
def main():
|
||||
"""Fonction principale de test"""
|
||||
print("🧪 Test rapide des API du VWB")
|
||||
print("=" * 50)
|
||||
print(f"🔗 URL Backend: {BASE_URL}")
|
||||
print("=" * 50)
|
||||
|
||||
# Tests ordonnés par importance
|
||||
tests = [
|
||||
("Statut Backend", test_backend_status),
|
||||
("Health Check", test_health),
|
||||
("Screen Capture", test_screen_capture),
|
||||
("Element Detection", test_element_detection),
|
||||
("Workflow CRUD", test_workflow_crud),
|
||||
]
|
||||
|
||||
results = []
|
||||
for name, test_func in tests:
|
||||
print(f"\n📋 Test: {name}")
|
||||
print("-" * 30)
|
||||
try:
|
||||
result = test_func()
|
||||
results.append(result)
|
||||
status = "✅ SUCCÈS" if result else "❌ ÉCHEC"
|
||||
print(f"Résultat: {status}")
|
||||
except Exception as e:
|
||||
print(f"❌ Erreur critique: {e}")
|
||||
results.append(False)
|
||||
|
||||
# Résumé final
|
||||
passed = sum(results)
|
||||
total = len(results)
|
||||
success_rate = (passed / total) * 100 if total > 0 else 0
|
||||
|
||||
print("\n" + "=" * 50)
|
||||
print(f"📊 RÉSULTAT FINAL: {passed}/{total} tests passés ({success_rate:.1f}%)")
|
||||
|
||||
if passed == total:
|
||||
print("🎉 Toutes les API principales fonctionnent parfaitement !")
|
||||
return 0
|
||||
elif passed >= total * 0.7:
|
||||
print("⚠️ La plupart des API fonctionnent, quelques problèmes mineurs")
|
||||
return 1
|
||||
else:
|
||||
print("🚨 Problèmes majeurs détectés dans le backend")
|
||||
return 2
|
||||
|
||||
if __name__ == "__main__":
|
||||
exit_code = main()
|
||||
sys.exit(exit_code)
|
||||
Reference in New Issue
Block a user