fix tests

This commit is contained in:
2025-11-15 12:35:51 +01:00
parent f91875f6fc
commit f49598d82b
11 changed files with 7107 additions and 2006 deletions

View File

@@ -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