test_config_ui.py•2.36 kB
"""Test script for configuration UI - verifies imports and basic functionality."""
import sys
from pathlib import Path
# Test imports
try:
from src.delegation_mcp.ui import create_app, ConfigurationManager
print("✅ Successfully imported create_app and ConfigurationManager")
except ImportError as e:
print(f"❌ Import error: {e}")
sys.exit(1)
# Test ConfigurationManager initialization
try:
config_manager = ConfigurationManager()
print("✅ ConfigurationManager initialized successfully")
except Exception as e:
print(f"❌ ConfigurationManager initialization failed: {e}")
sys.exit(1)
# Test agent status retrieval
try:
statuses = config_manager.get_agent_statuses()
print(f"✅ Retrieved {len(statuses)} agent statuses")
for status in statuses:
print(f" {status.status_icon} {status.name}: {status.status_text}")
except Exception as e:
print(f"❌ Failed to get agent statuses: {e}")
sys.exit(1)
# Test YAML validation
try:
test_yaml = """
- pattern: test
delegate_to: claude
priority: 5
"""
is_valid, message, rules = config_manager.validate_routing_rules(test_yaml)
if is_valid:
print(f"✅ YAML validation works: {message}")
else:
print(f"⚠️ YAML validation returned: {message}")
except Exception as e:
print(f"❌ YAML validation failed: {e}")
sys.exit(1)
# Test preview generation
try:
preview = config_manager.preview_routing_rules(rules if rules else [])
print(f"✅ Preview generation works (length: {len(preview)} chars)")
except Exception as e:
print(f"❌ Preview generation failed: {e}")
sys.exit(1)
# Test primary orchestrator setting
try:
current_primary = config_manager.primary_orchestrator
print(f"✅ Current primary orchestrator: {current_primary}")
except Exception as e:
print(f"❌ Failed to get primary orchestrator: {e}")
sys.exit(1)
# Test app creation (don't launch)
try:
app = create_app(config_manager)
print("✅ Gradio app created successfully")
except Exception as e:
print(f"❌ App creation failed: {e}")
sys.exit(1)
print("\n🎉 All tests passed! The configuration UI is ready to use.")
print("\nTo launch the UI, run:")
print(" python -m src.delegation_mcp.ui.app")
print("or use:")
print(" from src.delegation_mcp.ui import main")
print(" main()")