refactor: update tests to use async mocks and improve readability
CI / lint-test-build (push) Failing after 12s

This commit is contained in:
2026-06-07 15:05:42 +02:00
parent ef22e217c7
commit af0ac94a12
5 changed files with 251 additions and 346 deletions
+11 -7
View File
@@ -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")