swadhin biswas Ok batman Β· 7/28/2025
fb9342e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/usr/bin/env python3
"""
Test script for LaxyFile component integration
This script tests if all components can be properly initialized and integrated.
"""
import asyncio
import sys
from pathlib import Path
# Add the laxyfile directory to the path
sys.path.insert(0, str(Path(__file__).parent))
from laxyfile.core.config import Config
from laxyfile.integration.component_integration import initialize_integration
from laxyfile.utils.logging_system import initialize_logging
async def test_component_integration():
"""Test the component integration system"""
print("π Testing LaxyFile Component Integration")
print("=" * 50)
try:
# Initialize configuration
print("1. Initializing configuration...")
config = Config()
print(" β
Configuration initialized")
# Initialize logging system
print("\n2. Initializing logging system...")
logging_system = initialize_logging(config)
print(" β
Logging system initialized")
# Initialize component integrator
print("\n3. Initializing component integrator...")
integrator = initialize_integration(config)
print(" β
Component integrator created")
# Initialize all components
print("\n4. Initializing all components...")
success = await integrator.initialize_all_components()
if success:
print(" β
All components initialized successfully")
else:
print(" β Component initialization failed")
return False
# Test component interactions
print("\n5. Testing component interactions...")
test_results = await integrator.test_component_interactions()
print(" Test Results:")
for test_name, result in test_results.items():
status = "β
" if result else "β"
print(f" {status} {test_name}")
# Check overall health
print("\n6. Checking system health...")
is_healthy = integrator.is_healthy()
print(f" {'β
' if is_healthy else 'β'} System health: {'Healthy' if is_healthy else 'Unhealthy'}")
# Get component status
print("\n7. Component Status:")
component_status = integrator.get_all_component_status()
for name, status in component_status.items():
health_icon = "β
" if status.healthy else "β"
init_icon = "β
" if status.initialized else "β"
print(f" {name}: {init_icon} Init {health_icon} Health")
if status.error_message:
print(f" Error: {status.error_message}")
# Test getting components
print("\n8. Testing component access...")
components_to_test = [
'config', 'file_manager', 'ai_assistant',
'preview_system', 'file_operations', 'ui_manager', 'plugin_manager'
]
for component_name in components_to_test:
component = integrator.get_component(component_name)
status = "β
" if component is not None else "β"
print(f" {status} {component_name}: {type(component).__name__ if component else 'None'}")
# Shutdown
print("\n9. Shutting down...")
await integrator.shutdown()
print(" β
Shutdown complete")
print("\n" + "=" * 50)
print("π Integration test completed successfully!")
return True
except Exception as e:
print(f"\nβ Integration test failed: {e}")
import traceback
traceback.print_exc()
return False
async def test_basic_functionality():
"""Test basic functionality of integrated components"""
print("\nπ§ Testing Basic Functionality")
print("=" * 50)
try:
# Initialize system
config = Config()
logging_system = initialize_logging(config)
integrator = initialize_integration(config)
await integrator.initialize_all_components()
# Test file manager
print("1. Testing file manager...")
file_manager = integrator.get_component('file_manager')
if file_manager:
current_dir = Path.cwd()
files = await file_manager.list_directory(current_dir)
print(f" β
Listed {len(files)} files in current directory")
else:
print(" β File manager not available")
# Test AI assistant
print("\n2. Testing AI assistant...")
ai_assistant = integrator.get_component('ai_assistant')
if ai_assistant:
# Test with a simple query (this might fail if no AI models are configured)
try:
response = await ai_assistant.process_query("Hello, test query")
if response.get('success'):
print(" β
AI assistant responded successfully")
else:
print(f" β οΈ AI assistant responded with error: {response.get('error', 'Unknown')}")
except Exception as e:
print(f" β οΈ AI assistant test failed (expected if no models configured): {e}")
else:
print(" β AI assistant not available")
# Test preview system
print("\n3. Testing preview system...")
preview_system = integrator.get_component('preview_system')
if preview_system:
# Test preview generation for this script
test_file = Path(__file__)
preview = await preview_system.generate_preview(test_file)
if preview.success:
print(f" β
Generated preview for {test_file.name}")
else:
print(f" β οΈ Preview generation failed: {preview.error_message}")
else:
print(" β Preview system not available")
# Test plugin manager
print("\n4. Testing plugin manager...")
plugin_manager = integrator.get_component('plugin_manager')
if plugin_manager:
plugins = plugin_manager.list_plugins()
print(f" β
Plugin manager loaded with {len(plugins)} plugins")
else:
print(" β Plugin manager not available")
# Shutdown
await integrator.shutdown()
print("\n" + "=" * 50)
print("π Basic functionality test completed!")
return True
except Exception as e:
print(f"\nβ Basic functionality test failed: {e}")
import traceback
traceback.print_exc()
return False
async def main():
"""Main test function"""
print("LaxyFile Integration Test Suite")
print("=" * 60)
# Run integration test
integration_success = await test_component_integration()
if integration_success:
# Run basic functionality test
functionality_success = await test_basic_functionality()
if functionality_success:
print("\nπ All tests passed! Integration is working correctly.")
return 0
else:
print("\nβ οΈ Integration test passed but functionality test failed.")
return 1
else:
print("\nβ Integration test failed.")
return 1
if __name__ == "__main__":
exit_code = asyncio.run(main())
sys.exit(exit_code)