| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- #!/usr/bin/env python3
- """
- Integration test for Trixy voice assistant components.
- """
- import sys
- import time
- from trixy_core import create_application, DeploymentMode
- from trixy_core.events import EventType
- def test_basic_integration():
- """Test basic integration of all components."""
- print("=== Trixy Integration Test ===")
-
- try:
- # Create application
- print("1. Creating application...")
- app = create_application(mode=DeploymentMode.STANDALONE, debug_mode=True)
-
- # Start application
- print("2. Starting application...")
- app.start()
-
- # Test component access
- print("3. Testing component access...")
- event_handler = app.get_event_handler()
- config_manager = app.get_config_manager()
- plugin_system = app.get_plugin_system()
- network_manager = app.get_network_manager()
- scheduler = app.get_scheduler()
- conversation_manager = app.get_conversation_manager()
- asset_manager = app.get_asset_manager()
- arbitration_manager = app.get_arbitration_manager()
-
- print("✓ All components accessible")
-
- # Test event system
- print("4. Testing event system...")
- event_handler.trigger_event(EventType.SYSTEM_STARTUP)
- print("✓ Event triggered successfully")
-
- # Test asset manager
- print("5. Testing asset manager...")
- success_audio = asset_manager.get_path("audio/success.wav")
- print(f"✓ Asset found: {success_audio}")
-
- # Test configuration
- print("6. Testing configuration...")
- config = config_manager.get_config()
- print(f"✓ Config loaded: network ports={config.network.command_port}")
-
- # Test plugin system
- print("7. Testing plugin system...")
- plugin_count = len(plugin_system._plugins)
- print(f"✓ Plugins loaded: {plugin_count} plugins")
-
- # Test health check
- print("8. Testing health check...")
- health = app.get_health_report()
- print(f"✓ System healthy: {health['healthy']}")
-
- print("\n=== All Tests Passed! ===")
- return True
-
- except Exception as e:
- print(f"✗ Test failed: {e}")
- import traceback
- traceback.print_exc()
- return False
-
- finally:
- print("9. Shutting down...")
- try:
- app.shutdown()
- print("✓ Shutdown completed")
- except:
- pass
- def test_event_workflow():
- """Test a basic conversation workflow."""
- print("\n=== Testing Event Workflow ===")
-
- try:
- app = create_application(mode=DeploymentMode.STANDALONE, debug_mode=True)
- app.start()
-
- event_handler = app.get_event_handler()
-
- # Simulate wakeword detection
- print("1. Simulating wakeword detection...")
- from trixy_core.events.event_data import SpeakerInfo, SatelliteInfo
-
- speaker_info = SpeakerInfo(speaker_id="user1", speaker_name="Test User")
- satellite_info = SatelliteInfo(
- satellite_id="test_sat",
- mac_address="AA:BB:CC:DD:EE:FF",
- room_id="test_room",
- alias="Test Satellite",
- version="1.0.0"
- )
-
- event_handler.trigger_event(
- EventType.WAKEWORD_RECEIVED,
- wakeword_id="trixy",
- speaker_info=speaker_info,
- satellite_info=satellite_info,
- volume=0.8
- )
-
- print("✓ Wakeword event triggered")
-
- # Check event history
- history = event_handler.get_event_history(limit=5)
- print(f"✓ Event history contains {len(history)} events")
-
- print("=== Event Workflow Test Passed! ===")
- return True
-
- except Exception as e:
- print(f"✗ Event workflow test failed: {e}")
- import traceback
- traceback.print_exc()
- return False
-
- finally:
- try:
- app.shutdown()
- except:
- pass
- if __name__ == "__main__":
- success = True
-
- # Run basic integration test
- if not test_basic_integration():
- success = False
-
- # Run event workflow test
- if not test_event_workflow():
- success = False
-
- if success:
- print("\n🎉 All integration tests passed!")
- sys.exit(0)
- else:
- print("\n❌ Some tests failed!")
- sys.exit(1)
|