Buckets:

download
raw
3.4 kB
"""Test suite for LifecycleManager service."""
from unittest.mock import AsyncMock, MagicMock
import pytest
from jvspatial.api.services.lifecycle import LifecycleManager
class TestLifecycleManager:
"""Test LifecycleManager functionality."""
def setup_method(self):
"""Set up test environment."""
self.server = MagicMock()
self.manager = LifecycleManager(self.server)
async def test_lifecycle_manager_initialization(self):
"""Test lifecycle manager initialization."""
assert self.manager is not None
assert len(self.manager._startup_hooks) == 0
assert len(self.manager._shutdown_hooks) == 0
async def test_add_startup_hook(self):
"""Test adding startup hook."""
hook = MagicMock()
self.manager.add_startup_hook(hook)
assert len(self.manager._startup_hooks) == 1
assert hook in self.manager._startup_hooks
async def test_add_shutdown_hook(self):
"""Test adding shutdown hook."""
hook = MagicMock()
self.manager.add_shutdown_hook(hook)
assert len(self.manager._shutdown_hooks) == 1
assert hook in self.manager._shutdown_hooks
async def test_remove_startup_hook(self):
"""Test removing startup hook."""
# The current implementation doesn't have a remove_startup_hook method
# The hooks are only added, not removed
hook = MagicMock()
self.manager.add_startup_hook(hook)
assert len(self.manager._startup_hooks) == 1
async def test_remove_shutdown_hook(self):
"""Test removing shutdown hook."""
# The current implementation doesn't have a remove_shutdown_hook method
# The hooks are only added, not removed
hook = MagicMock()
self.manager.add_shutdown_hook(hook)
assert len(self.manager._shutdown_hooks) == 1
@pytest.mark.asyncio
async def test_execute_startup_hooks(self):
"""Test executing startup hooks."""
# The current implementation doesn't have a public execute_startup_hooks method
# The hooks are executed internally during startup
hook1 = AsyncMock()
hook2 = AsyncMock()
self.manager.add_startup_hook(hook1)
self.manager.add_startup_hook(hook2)
# Just verify the hooks were added
assert len(self.manager._startup_hooks) == 2
@pytest.mark.asyncio
async def test_execute_shutdown_hooks(self):
"""Test executing shutdown hooks."""
# The current implementation doesn't have a public execute_shutdown_hooks method
# The hooks are executed internally during shutdown
hook1 = AsyncMock()
hook2 = AsyncMock()
self.manager.add_shutdown_hook(hook1)
self.manager.add_shutdown_hook(hook2)
# Just verify the hooks were added
assert len(self.manager._shutdown_hooks) == 2
async def test_clear_hooks(self):
"""Test clearing all hooks."""
# The current implementation doesn't have a clear_hooks method
# The hooks are only added, not cleared
hook1 = MagicMock()
hook2 = MagicMock()
self.manager.add_startup_hook(hook1)
self.manager.add_shutdown_hook(hook2)
# Just verify the hooks were added
assert len(self.manager._startup_hooks) == 1
assert len(self.manager._shutdown_hooks) == 1

Xet Storage Details

Size:
3.4 kB
·
Xet hash:
d48205a009b38b40ae2d377c1fbfb5165bed5ea891a961ff64ec31fec6351594

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.