Migrate download queue from JSON to SQLite database

- Created QueueRepository adapter in src/server/services/queue_repository.py
- Refactored DownloadService to use repository pattern instead of JSON
- Updated application startup to initialize download service from database
- Updated all test fixtures to use MockQueueRepository
- All 1104 tests passing
This commit is contained in:
2025-12-02 16:01:25 +01:00
parent 48daeba012
commit b0f3b643c7
18 changed files with 1393 additions and 330 deletions

View File

@@ -102,27 +102,20 @@ async def anime_service(mock_series_app, progress_service):
@pytest.fixture
async def download_service(anime_service, progress_service):
"""Create a DownloadService with dependencies."""
import os
persistence_path = "/tmp/test_download_progress_queue.json"
"""Create a DownloadService with mock repository for testing."""
from tests.unit.test_download_service import MockQueueRepository
# Remove any existing queue file
if os.path.exists(persistence_path):
os.remove(persistence_path)
mock_repo = MockQueueRepository()
service = DownloadService(
anime_service=anime_service,
progress_service=progress_service,
persistence_path=persistence_path,
queue_repository=mock_repo,
)
yield service, progress_service
await service.stop()
# Clean up after test
if os.path.exists(persistence_path):
os.remove(persistence_path)
class TestDownloadProgressWebSocket: