fix(folder_scan): await NFO repair before folder rename
folder_rename_service depends on clean NFO files but repair tasks were fire-and-forget. Now collect all repair tasks and await them with asyncio.gather before validate_and_rename_series_folders runs. Also update tests that mock asyncio.create_task to also mock asyncio.gather since perform_nfo_repair_scan now awaits tasks.
This commit is contained in:
@@ -816,11 +816,14 @@ class TestPerformNfoRepairScan:
|
||||
return_value=mock_repair_service,
|
||||
), patch(
|
||||
"asyncio.create_task"
|
||||
) as mock_create_task:
|
||||
) as mock_create_task, patch(
|
||||
"asyncio.gather", new_callable=AsyncMock
|
||||
) as mock_gather:
|
||||
mock_factory_cls.return_value.create.return_value = MagicMock()
|
||||
await perform_nfo_repair_scan(background_loader=AsyncMock())
|
||||
|
||||
mock_create_task.assert_called_once()
|
||||
mock_gather.assert_called_once()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_skips_complete_series(self, tmp_path):
|
||||
@@ -876,8 +879,11 @@ class TestPerformNfoRepairScan:
|
||||
return_value=mock_repair_service,
|
||||
), patch(
|
||||
"asyncio.create_task"
|
||||
) as mock_create_task:
|
||||
) as mock_create_task, patch(
|
||||
"asyncio.gather", new_callable=AsyncMock
|
||||
) as mock_gather:
|
||||
mock_factory_cls.return_value.create.return_value = MagicMock()
|
||||
await perform_nfo_repair_scan(background_loader=None)
|
||||
|
||||
mock_create_task.assert_called_once()
|
||||
mock_gather.assert_called_once()
|
||||
|
||||
Reference in New Issue
Block a user