Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """Test script for dependency injection implementation.""" | |
| import sys | |
| import os | |
| # Add src to path | |
| sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src')) | |
| try: | |
| from infrastructure.config.dependency_container import DependencyContainer, get_container | |
| from infrastructure.config.app_config import AppConfig | |
| from infrastructure.tts.provider_factory import TTSProviderFactory | |
| from infrastructure.stt.provider_factory import STTProviderFactory | |
| from infrastructure.translation.provider_factory import TranslationProviderFactory | |
| print("π§ͺ Testing Dependency Injection Implementation...") | |
| print() | |
| # Test basic container functionality | |
| container = DependencyContainer() | |
| print('β DependencyContainer created successfully') | |
| # Test configuration resolution | |
| config = container.resolve(AppConfig) | |
| print(f'β AppConfig resolved: {type(config).__name__}') | |
| # Test factory resolution | |
| tts_factory = container.resolve(TTSProviderFactory) | |
| stt_factory = container.resolve(STTProviderFactory) | |
| translation_factory = container.resolve(TranslationProviderFactory) | |
| print(f'β TTSProviderFactory resolved: {type(tts_factory).__name__}') | |
| print(f'β STTProviderFactory resolved: {type(stt_factory).__name__}') | |
| print(f'β TranslationProviderFactory resolved: {type(translation_factory).__name__}') | |
| # Test global container | |
| global_container = get_container() | |
| print(f'β Global container retrieved: {type(global_container).__name__}') | |
| # Test service registration info | |
| services = container.get_registered_services() | |
| print(f'β Registered services: {len(services)} services') | |
| for service_name, lifetime in services.items(): | |
| print(f' - {service_name}: {lifetime}') | |
| # Test cleanup | |
| container.cleanup() | |
| print('β Container cleanup completed') | |
| print() | |
| print('π All dependency injection tests passed!') | |
| except Exception as e: | |
| print(f'β Test failed: {e}') | |
| import traceback | |
| traceback.print_exc() | |
| sys.exit(1) |