refactor: update tests to use async mocks and improve readability
CI / lint-test-build (push) Failing after 12s
CI / lint-test-build (push) Failing after 12s
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
"""End-to-end test for configuration management system."""
|
||||
|
||||
from unittest.mock import MagicMock, Mock, patch
|
||||
from unittest.mock import AsyncMock, MagicMock, Mock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from arbitrade.config.service import ConfigurationService
|
||||
from arbitrade.config.settings import Settings
|
||||
from arbitrade.storage.repositories import AuditRepository
|
||||
|
||||
|
||||
def test_end_to_end_config_workflow():
|
||||
@pytest.mark.asyncio
|
||||
async def test_end_to_end_config_workflow():
|
||||
"""Test complete configuration workflow."""
|
||||
# Create mocks
|
||||
settings = Mock(spec=Settings)
|
||||
@@ -36,13 +39,14 @@ def test_end_to_end_config_workflow():
|
||||
# Mock the setting creation
|
||||
mock_created_setting = Mock()
|
||||
mock_created_setting.updated_at = "2023-01-01T00:00:00"
|
||||
mock_repo_instance.create_setting.return_value = mock_created_setting
|
||||
mock_repo_instance.get_setting.return_value = None
|
||||
mock_repo_instance.get_latest_updated_at.return_value = None
|
||||
mock_repo_instance.list_settings.return_value = []
|
||||
mock_repo_instance.create_setting = AsyncMock(
|
||||
return_value=mock_created_setting)
|
||||
mock_repo_instance.get_setting = AsyncMock(return_value=None)
|
||||
mock_repo_instance.get_latest_updated_at = AsyncMock(return_value=None)
|
||||
mock_repo_instance.list_settings = AsyncMock(return_value=[])
|
||||
|
||||
# Set a setting
|
||||
service.set_setting("test_key", "test_value", "test_user")
|
||||
await service.set_setting("test_key", "test_value", "test_user")
|
||||
|
||||
# Verify setting was retrieved
|
||||
result = service.get_setting("test_key", "default")
|
||||
|
||||
Reference in New Issue
Block a user