Fix first refresh watchlist auto-download backlog

This commit is contained in:
Dymas
2026-05-26 19:37:20 +02:00
parent bf4fdc79f5
commit 7a0fa024ed
5 changed files with 63 additions and 5 deletions
+54
View File
@@ -2422,6 +2422,60 @@ class AutoDownloadQueueTests(unittest.TestCase):
}
)
def test_queue_watchlist_auto_download_can_queue_backlog_on_first_manual_refresh(self):
item = {
"show_id": "show-first-refresh",
"title": "First Refresh Show",
"category": "watching",
"previous_last_checked": None,
"had_new_episodes": False,
"dub_episode_values": ["1", "2", "3"],
"sub_episode_values": [],
"auto_download_mode": "dub",
"auto_download_quality": "best",
"auto_download_name": "First Refresh Show",
"auto_download_series": "1",
"auto_download_offset": None,
"downloaded_dub_episodes": [],
"downloaded_sub_episodes": [],
}
download_queue = mock.Mock()
download_queue.covered_episodes.return_value = set()
download_queue.add.return_value = {"id": "job-first-refresh", "episodes": "1-3"}
runtime = {
"config": {
"auto_download_enabled": True,
"auto_download_mode": "dub",
"auto_download_quality": "best",
"download_dir": "/tmp/downloads",
},
"download_queue": download_queue,
}
with mock.patch.object(APP, "ensure_runtime", return_value=runtime), mock.patch.object(
APP,
"search_anime",
side_effect=AssertionError("search should not be required"),
):
result = APP.queue_watchlist_auto_download(item, refresh_source="manual")
self.assertTrue(result["queued"])
self.assertEqual(result["episodes"], ["1-3"])
download_queue.add.assert_called_once_with(
{
"show_id": "show-first-refresh",
"query": "First Refresh Show",
"title": "First Refresh Show",
"anime_name": "First Refresh Show",
"media_type": "tv",
"season": "1",
"episode_offset": None,
"mode": "dub",
"quality": "best",
"episodes": "1-3",
"download_dir": "/tmp/downloads",
}
)
def test_queue_watchlist_auto_download_passes_episode_offset_to_jobs(self):
item = {
"show_id": "show-77",