fix tests
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
"""Pytest configuration and shared fixtures for all tests."""
|
||||
|
||||
from unittest.mock import Mock
|
||||
|
||||
import pytest
|
||||
|
||||
from src.server.services.auth_service import auth_service
|
||||
@@ -75,6 +77,7 @@ def reset_auth_and_rate_limits(request):
|
||||
# but we continue anyway - they're not critical
|
||||
pass
|
||||
|
||||
|
||||
yield
|
||||
|
||||
# Clean up after test
|
||||
@@ -82,4 +85,32 @@ def reset_auth_and_rate_limits(request):
|
||||
auth_service._failed.clear() # noqa: SLF001
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_series_app_download(monkeypatch):
|
||||
"""Mock SeriesApp loader download to prevent real downloads in tests.
|
||||
|
||||
This fixture automatically mocks all download operations to prevent
|
||||
tests from performing real network downloads.
|
||||
Applied to all tests automatically via autouse=True.
|
||||
"""
|
||||
# Mock the loader download method
|
||||
try:
|
||||
from src.core.SeriesApp import SeriesApp
|
||||
|
||||
# Patch the loader.download method for all SeriesApp instances
|
||||
original_init = SeriesApp.__init__
|
||||
|
||||
def patched_init(self, *args, **kwargs):
|
||||
original_init(self, *args, **kwargs)
|
||||
# Mock the loader's download method
|
||||
if hasattr(self, 'loader'):
|
||||
self.loader.download = Mock(return_value=True)
|
||||
|
||||
monkeypatch.setattr(SeriesApp, '__init__', patched_init)
|
||||
|
||||
except ImportError:
|
||||
# If imports fail, tests will continue but may perform downloads
|
||||
pass
|
||||
|
||||
yield
|
||||
|
||||
|
||||
Reference in New Issue
Block a user