Backfill watchlist alternative titles lazily
This commit is contained in:
+21
@@ -866,6 +866,16 @@ class WatchlistCompletionTests(unittest.TestCase):
|
||||
self.assertEqual(item["english_title"], "Example Show English")
|
||||
self.assertEqual(item["display_alt_titles"], ["Example Show English", "Sample Alias"])
|
||||
|
||||
def test_ensure_alt_titles_backfills_existing_item(self):
|
||||
self.seed_watchlist_item()
|
||||
with mock.patch.object(
|
||||
APP, "fetch_allmanga_alternative_titles", return_value={"english_title": "Example Show English", "alt_titles": ["Example Show English", "Sample Alias"]}
|
||||
):
|
||||
item = APP.WATCHLIST.ensure_alt_titles("show-1")
|
||||
|
||||
self.assertEqual(item["english_title"], "Example Show English")
|
||||
self.assertEqual(item["display_alt_titles"], ["Example Show English", "Sample Alias"])
|
||||
|
||||
def test_list_filters_by_category_and_reports_category_counts(self):
|
||||
self.seed_watchlist_item(show_id="show-1", title="Watching Show", category="watching", status="queued")
|
||||
self.seed_watchlist_item(show_id="show-2", title="Finished Show", category="finished", downloaded=True)
|
||||
@@ -1661,6 +1671,15 @@ class HandlerRouteTests(unittest.TestCase):
|
||||
self.assertEqual(handler.json_payload, payload)
|
||||
self.assertEqual(handler.json_status, HTTPStatus.CREATED)
|
||||
|
||||
def test_watchlist_ensure_alt_titles_post_returns_items(self):
|
||||
body = b'{"show_ids":["show-1"],"limit":1}'
|
||||
handler = DummyHandler("/api/watchlist/ensure-alt-titles", body=body, content_length=len(body))
|
||||
payload = {"items": [{"show_id": "show-1", "display_alt_titles": ["Example Show English"]}]}
|
||||
with mock.patch.object(APP.WATCHLIST, "ensure_alt_titles_many", return_value=payload):
|
||||
APP.Handler.do_POST(handler)
|
||||
self.assertEqual(handler.json_payload, payload)
|
||||
self.assertEqual(handler.json_status, HTTPStatus.OK)
|
||||
|
||||
def test_generic_handler_exception_skips_traceback_when_debug_disabled(self):
|
||||
handler = DummyHandler("/api/config")
|
||||
with mock.patch.object(http_handler, "debug_enabled", return_value=False), mock.patch.object(
|
||||
@@ -1750,6 +1769,8 @@ class TemplateHelperTests(unittest.TestCase):
|
||||
self.assertIn('class="alt-titles"', APP.WATCHLIST_HTML)
|
||||
self.assertIn('Alternative titles', APP.WATCHLIST_HTML)
|
||||
self.assertIn('altTitlesNode.classList.toggle("visible")', APP.WATCHLIST_HTML)
|
||||
self.assertIn('api("/api/watchlist/ensure-alt-titles"', APP.WATCHLIST_HTML)
|
||||
self.assertIn("altTitlePending: new Set()", APP.WATCHLIST_HTML)
|
||||
|
||||
def test_watchlist_thumbnail_warmup_skips_repeated_attempts(self):
|
||||
self.assertIn("thumbnailWarmupPending: new Set()", APP.WATCHLIST_HTML)
|
||||
|
||||
Reference in New Issue
Block a user