test: fix NFO workflow and background loader tests
- Add missing TMDB async mock methods (_ensure_session, close) to all TMDB mocks in test_nfo_workflow.py - Refactor test_anime_add_nfo_isolation.py to mock get_nfo_factory() instead of asserting on series_app.nfo_service directly - Patch get_nfo_factory in test_background_loader_service.py to align with factory-based NFOService creation Fixes test failures caused by NFOService refactoring that introduced explicit TMDB session lifecycle and NFO factory pattern.
This commit is contained in:
@@ -520,19 +520,25 @@ class TestLoadNfoAndImages:
|
||||
mock_db = AsyncMock()
|
||||
mock_series = MagicMock()
|
||||
mock_series.has_nfo = False
|
||||
|
||||
|
||||
task = SeriesLoadingTask(
|
||||
key="test",
|
||||
folder="test_folder",
|
||||
name="Test Series",
|
||||
year=2020
|
||||
)
|
||||
|
||||
with patch("src.server.database.service.AnimeSeriesService") as mock_service_class:
|
||||
|
||||
mock_nfo_service = AsyncMock()
|
||||
mock_nfo_service.create_tvshow_nfo = AsyncMock(return_value="/anime/test_folder/tvshow.nfo")
|
||||
mock_factory = MagicMock()
|
||||
mock_factory.create = MagicMock(return_value=mock_nfo_service)
|
||||
|
||||
with patch("src.server.database.service.AnimeSeriesService") as mock_service_class, \
|
||||
patch("src.server.services.background_loader_service.get_nfo_factory", return_value=mock_factory):
|
||||
mock_service_class.get_by_key = AsyncMock(return_value=mock_series)
|
||||
|
||||
|
||||
result = await background_loader_service._load_nfo_and_images(task, mock_db)
|
||||
|
||||
|
||||
assert result is True
|
||||
assert task.progress["nfo"] is True
|
||||
assert task.progress["logo"] is True
|
||||
|
||||
Reference in New Issue
Block a user