Refactor: Replace CallbackManager with Events pattern

- Replace callback system with events library in SerieScanner
- Update SeriesApp to subscribe to loader and scanner events
- Refactor ScanService to use Events instead of CallbackManager
- Remove CallbackManager imports and callback classes
- Add safe event calling with error handling in SerieScanner
- Update AniworldLoader to use Events for download progress
- Remove progress_callback parameter from download methods
- Update all affected tests for Events pattern
- Fix test_series_app.py for new event subscription model
- Comment out obsolete callback tests in test_scan_service.py

All core tests passing. Events provide cleaner event-driven architecture.
This commit is contained in:
2025-12-30 21:04:45 +01:00
parent ff9dea0488
commit b1726968e5
8 changed files with 381 additions and 631 deletions

View File

@@ -1,29 +1,17 @@
"""Unit tests for ScanService.
This module contains comprehensive tests for the scan service,
including scan lifecycle, progress callbacks, event handling,
and key-based identification.
including scan lifecycle, progress events, and key-based identification.
"""
from datetime import datetime
from unittest.mock import AsyncMock, MagicMock
from unittest.mock import AsyncMock, MagicMock, Mock
import pytest
from src.core.interfaces.callbacks import (
CallbackManager,
CompletionContext,
ErrorContext,
OperationType,
ProgressContext,
ProgressPhase,
)
from src.server.services.scan_service import (
ScanProgress,
ScanService,
ScanServiceCompletionCallback,
ScanServiceError,
ScanServiceErrorCallback,
ScanServiceProgressCallback,
get_scan_service,
reset_scan_service,
)