refactor: remove GlobalLogger and migrate to standard Python logging
- Remove src/infrastructure/logging/GlobalLogger.py - Update SerieScanner.py to use standard logging.getLogger() - Update aniworld_provider.py to remove custom noKeyFound_logger setup - Fix test_dependencies.py to properly mock config_service - Fix code style issues (line length, formatting) - All 846 tests passing
This commit is contained in:
@@ -50,11 +50,21 @@ class TestSeriesAppDependency:
|
||||
assert result == mock_series_app_instance
|
||||
mock_series_app_class.assert_called_once_with("/path/to/anime")
|
||||
|
||||
@patch('src.server.services.config_service.get_config_service')
|
||||
@patch('src.server.utils.dependencies.settings')
|
||||
def test_get_series_app_no_directory_configured(self, mock_settings):
|
||||
def test_get_series_app_no_directory_configured(
|
||||
self, mock_settings, mock_get_config_service
|
||||
):
|
||||
"""Test SeriesApp dependency when directory is not configured."""
|
||||
# Arrange
|
||||
mock_settings.anime_directory = ""
|
||||
|
||||
# Mock config service to return empty config
|
||||
mock_config_service = Mock()
|
||||
mock_config = Mock()
|
||||
mock_config.other = {}
|
||||
mock_config_service.load_config.return_value = mock_config
|
||||
mock_get_config_service.return_value = mock_config_service
|
||||
|
||||
# Act & Assert
|
||||
with pytest.raises(HTTPException) as exc_info:
|
||||
@@ -178,8 +188,10 @@ class TestAuthenticationDependencies:
|
||||
mock_get_current_user.assert_called_once_with(credentials)
|
||||
|
||||
@patch('src.server.utils.dependencies.get_current_user')
|
||||
def test_optional_auth_with_invalid_credentials(self,
|
||||
mock_get_current_user):
|
||||
def test_optional_auth_with_invalid_credentials(
|
||||
self,
|
||||
mock_get_current_user
|
||||
):
|
||||
"""Test optional authentication with invalid credentials."""
|
||||
# Arrange
|
||||
credentials = HTTPAuthorizationCredentials(
|
||||
@@ -277,6 +289,8 @@ class TestUtilityDependencies:
|
||||
await log_request_dependency(mock_request)
|
||||
|
||||
# Assert - no exception should be raised
|
||||
|
||||
|
||||
class TestIntegrationScenarios:
|
||||
"""Integration test scenarios for dependency injection."""
|
||||
|
||||
@@ -284,14 +298,18 @@ class TestIntegrationScenarios:
|
||||
"""Test the complete SeriesApp dependency lifecycle."""
|
||||
# Use separate mock instances for each call
|
||||
with patch('src.server.utils.dependencies.settings') as mock_settings:
|
||||
with patch('src.server.utils.dependencies.SeriesApp') as mock_series_app_class:
|
||||
with patch(
|
||||
'src.server.utils.dependencies.SeriesApp'
|
||||
) as mock_series_app_class:
|
||||
# Arrange
|
||||
mock_settings.anime_directory = "/path/to/anime"
|
||||
|
||||
# Create separate mock instances for each instantiation
|
||||
mock_instance1 = MagicMock()
|
||||
mock_instance2 = MagicMock()
|
||||
mock_series_app_class.side_effect = [mock_instance1, mock_instance2]
|
||||
mock_series_app_class.side_effect = [
|
||||
mock_instance1, mock_instance2
|
||||
]
|
||||
|
||||
# Act - Get SeriesApp instance
|
||||
app1 = get_series_app()
|
||||
|
||||
Reference in New Issue
Block a user