Fix movie watchlist completion sync

This commit is contained in:
Dymas
2026-05-26 07:26:54 +02:00
parent 28410b2946
commit ff605aca03
6 changed files with 56 additions and 9 deletions
+29 -1
View File
@@ -1251,6 +1251,24 @@ class WatchlistCompletionTests(unittest.TestCase):
self.assertEqual(item["finished_badge"], "downloaded")
self.assertEqual(item["downloaded_dub_episodes"], ["1", "2", "3"])
def test_mark_downloaded_moves_existing_movie_to_finished(self):
self.seed_watchlist_item(
show_id="movie-1",
title="Movie Show",
category="watching",
downloaded=False,
media_type="movie",
)
with mock.patch.object(APP.WATCHLIST, "schedule_refresh", side_effect=lambda show_id, source="manual": APP.WATCHLIST.get(show_id)), mock.patch.object(
APP.WATCHLIST, "refresh", side_effect=AssertionError("mark_downloaded should not refresh synchronously")
):
item = APP.WATCHLIST.mark_downloaded("movie-1", title="Movie Show", media_type="movie")
self.assertEqual(item["category"], "finished")
self.assertEqual(item["media_type"], "movie")
self.assertTrue(item["downloaded"])
def test_mark_downloaded_creates_missing_show_in_finished_category(self):
with mock.patch.object(APP.WATCHLIST, "schedule_refresh", side_effect=lambda show_id, source="manual": APP.WATCHLIST.get(show_id)), mock.patch.object(
APP.WATCHLIST, "refresh", side_effect=AssertionError("mark_downloaded should not refresh synchronously")
@@ -1262,6 +1280,16 @@ class WatchlistCompletionTests(unittest.TestCase):
self.assertEqual(item["finished_badge"], "downloaded")
self.assertEqual(item["status"], "queued")
def test_mark_downloaded_creates_missing_movie_in_finished_category(self):
with mock.patch.object(APP.WATCHLIST, "schedule_refresh", side_effect=lambda show_id, source="manual": APP.WATCHLIST.get(show_id)), mock.patch.object(
APP.WATCHLIST, "refresh", side_effect=AssertionError("mark_downloaded should not refresh synchronously")
):
item = APP.WATCHLIST.mark_downloaded("movie-2", title="Downloaded Movie", media_type="movie")
self.assertEqual(item["category"], "finished")
self.assertEqual(item["media_type"], "movie")
self.assertTrue(item["downloaded"])
def test_mark_downloaded_does_not_recreate_removed_show(self):
self.seed_watchlist_item(show_id="show-removed", title="Removed Show", category="watching")
@@ -1369,7 +1397,7 @@ class WatchlistCompletionTests(unittest.TestCase):
) as mark_downloaded:
APP.sync_downloaded_job_to_watchlist(job)
mark_downloaded.assert_called_once_with("show-42", title="Queue Show", mode="sub", episodes=None)
mark_downloaded.assert_called_once_with("show-42", title="Queue Show", mode="sub", episodes=None, media_type=None)
def test_prepare_download_job_persists_resolved_show_id(self):
job = {"query": "Queue Show", "mode": "sub", "result_index": 1, "title": "Queue Show", "show_id": ""}