mirror of
https://github.com/aljazceru/enclava.git
synced 2025-12-17 07:24:34 +01:00
remove workflow and fix dependencies
This commit is contained in:
@@ -23,10 +23,8 @@ sys.path.insert(0, str(backend_path))
|
||||
sys.path.insert(0, str(backend_path / "modules"))
|
||||
|
||||
try:
|
||||
from modules.cache.main import CacheModule
|
||||
from modules.rag.main import RAGModule
|
||||
from modules.chatbot.main import ChatbotModule
|
||||
from modules.workflow.main import WorkflowModule
|
||||
|
||||
from app.services.module_manager import ModuleManager, ModuleConfig
|
||||
except ImportError as e:
|
||||
@@ -50,17 +48,15 @@ except ImportError as e:
|
||||
def get_stats(self):
|
||||
return {"mock": True}
|
||||
|
||||
CacheModule = MockModule
|
||||
RAGModule = MockModule
|
||||
ChatbotModule = MockModule
|
||||
WorkflowModule = MockModule
|
||||
|
||||
# Mock ModuleManager for testing
|
||||
class MockModuleManager:
|
||||
def __init__(self):
|
||||
self.initialized = False
|
||||
self.modules = {}
|
||||
self.module_order = ['cache', 'rag', 'chatbot', 'workflow']
|
||||
self.module_order = ['rag', 'chatbot']
|
||||
|
||||
async def initialize(self):
|
||||
self.initialized = True
|
||||
@@ -94,26 +90,6 @@ except ImportError as e:
|
||||
class TestModuleIndividual:
|
||||
"""Test individual module functionality"""
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_cache_module_initialization(self):
|
||||
"""Test cache module initialization and basic operations"""
|
||||
cache_module = CacheModule()
|
||||
|
||||
# Test initialization
|
||||
result = await cache_module.initialize()
|
||||
assert result is True
|
||||
assert cache_module.initialized is True
|
||||
|
||||
# Test stats retrieval
|
||||
stats = cache_module.get_stats()
|
||||
assert isinstance(stats, dict)
|
||||
assert 'hits' in stats
|
||||
assert 'misses' in stats
|
||||
assert 'errors' in stats
|
||||
|
||||
# Test cleanup
|
||||
await cache_module.cleanup()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_chatbot_module_initialization(self):
|
||||
"""Test chatbot module initialization and basic operations"""
|
||||
@@ -148,60 +124,6 @@ class TestModuleIndividual:
|
||||
|
||||
await rag_module.cleanup()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_workflow_module_initialization(self):
|
||||
"""Test workflow module initialization and basic operations"""
|
||||
workflow_module = WorkflowModule()
|
||||
|
||||
# Test initialization
|
||||
result = await workflow_module.initialize()
|
||||
assert result is True
|
||||
assert workflow_module.initialized is True
|
||||
|
||||
# Test stats retrieval
|
||||
stats = workflow_module.get_stats()
|
||||
assert isinstance(stats, dict)
|
||||
|
||||
await workflow_module.cleanup()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_signal_module_initialization(self):
|
||||
"""Test signal bot module initialization and basic operations"""
|
||||
try:
|
||||
from modules.signal.main import SignalBotModule
|
||||
except ImportError as e:
|
||||
# Skip test if SignalBot dependencies not available
|
||||
pytest.skip(f"Signal bot module dependencies not available: {e}")
|
||||
|
||||
signal_module = SignalBotModule()
|
||||
|
||||
# Test initialization (may fail if SignalBot not available, which is OK)
|
||||
try:
|
||||
result = await signal_module.initialize()
|
||||
assert signal_module.module_id == "signal"
|
||||
|
||||
# Test configuration
|
||||
assert hasattr(signal_module, 'config')
|
||||
assert hasattr(signal_module, 'stats')
|
||||
|
||||
# Test permissions
|
||||
permissions = signal_module.get_required_permissions()
|
||||
assert len(permissions) == 3
|
||||
assert any(p.resource == "signal" and p.action == "manage" for p in permissions)
|
||||
|
||||
except ImportError:
|
||||
# SignalBot library not available, skip functionality tests
|
||||
pytest.skip("SignalBot library not available")
|
||||
except Exception as e:
|
||||
# Other initialization errors are acceptable for testing
|
||||
logger.info(f"Signal module initialization failed (expected): {e}")
|
||||
|
||||
# Test cleanup
|
||||
try:
|
||||
await signal_module.cleanup()
|
||||
except Exception:
|
||||
pass # Cleanup errors are acceptable
|
||||
|
||||
|
||||
class TestModuleIntegration:
|
||||
"""Test module integration and interactions"""
|
||||
@@ -216,19 +138,19 @@ class TestModuleIntegration:
|
||||
assert module_manager.initialized is True
|
||||
|
||||
# Check all expected modules are loaded
|
||||
expected_modules = ['cache', 'chatbot', 'rag', 'workflow', 'signal']
|
||||
expected_modules = ['chatbot', 'rag']
|
||||
loaded_modules = module_manager.list_modules()
|
||||
|
||||
for module_name in expected_modules:
|
||||
assert module_name in loaded_modules, f"Module {module_name} not loaded"
|
||||
|
||||
# Test module retrieval
|
||||
cache_module = module_manager.get_module('cache')
|
||||
assert cache_module is not None
|
||||
|
||||
rag_module = module_manager.get_module('rag')
|
||||
assert rag_module is not None
|
||||
|
||||
chatbot_module = module_manager.get_module('chatbot')
|
||||
assert chatbot_module is not None
|
||||
|
||||
await module_manager.cleanup()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -269,18 +191,18 @@ class TestModuleHotReload:
|
||||
await module_manager.initialize()
|
||||
|
||||
# Get initial module reference
|
||||
initial_module = module_manager.get_module('cache')
|
||||
initial_module = module_manager.get_module('rag')
|
||||
assert initial_module is not None
|
||||
|
||||
# Test reload
|
||||
await module_manager.reload_module('cache')
|
||||
await module_manager.reload_module('rag')
|
||||
|
||||
# Get module after reload
|
||||
reloaded_module = module_manager.get_module('cache')
|
||||
reloaded_module = module_manager.get_module('rag')
|
||||
assert reloaded_module is not None
|
||||
|
||||
# Module should be reloaded (may be same object or different)
|
||||
assert module_manager.is_module_loaded('cache')
|
||||
assert module_manager.is_module_loaded('rag')
|
||||
|
||||
await module_manager.cleanup()
|
||||
|
||||
@@ -304,26 +226,6 @@ class TestModulePerformance:
|
||||
|
||||
await module_manager.cleanup()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_cache_module_performance(self):
|
||||
"""Test cache module performance"""
|
||||
cache_module = CacheModule()
|
||||
await cache_module.initialize()
|
||||
|
||||
# Test multiple rapid operations
|
||||
start_time = time.time()
|
||||
|
||||
for i in range(10):
|
||||
stats = cache_module.get_stats()
|
||||
assert isinstance(stats, dict)
|
||||
|
||||
operations_time = time.time() - start_time
|
||||
|
||||
# 10 operations should complete quickly
|
||||
assert operations_time < 1.0, f"Cache operations took {operations_time:.2f}s"
|
||||
|
||||
await cache_module.cleanup()
|
||||
|
||||
|
||||
|
||||
class TestModuleErrorHandling:
|
||||
@@ -338,7 +240,7 @@ class TestModuleErrorHandling:
|
||||
await module_manager.initialize()
|
||||
|
||||
# At least some modules should load successfully
|
||||
assert len(module_manager.list_modules()) >= 5
|
||||
assert len(module_manager.list_modules()) >= 2
|
||||
|
||||
await module_manager.cleanup()
|
||||
|
||||
@@ -426,10 +328,6 @@ if __name__ == "__main__":
|
||||
# Test individual modules
|
||||
test_individual = TestModuleIndividual()
|
||||
|
||||
print("Testing cache module...")
|
||||
await test_individual.test_cache_module_initialization()
|
||||
print("✓ Cache module test passed")
|
||||
|
||||
print("Testing chatbot module...")
|
||||
await test_individual.test_chatbot_module_initialization()
|
||||
print("✓ Chatbot module test passed")
|
||||
@@ -438,14 +336,6 @@ if __name__ == "__main__":
|
||||
await test_individual.test_rag_module_initialization()
|
||||
print("✓ RAG module with content processing test passed")
|
||||
|
||||
print("Testing workflow module...")
|
||||
await test_individual.test_workflow_module_initialization()
|
||||
print("✓ Workflow module test passed")
|
||||
|
||||
print("Testing signal bot module...")
|
||||
await test_individual.test_signal_module_initialization()
|
||||
print("✓ Signal bot module test passed")
|
||||
|
||||
# Test integration
|
||||
test_integration = TestModuleIntegration()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user