Use AniDB for watchlist alternative titles
This commit is contained in:
+18
-24
@@ -621,7 +621,7 @@ class WatchlistRefreshJobTests(unittest.TestCase):
|
||||
self.assertIn("restart", status["message"].lower())
|
||||
|
||||
|
||||
class WatchlistAniListTests(unittest.TestCase):
|
||||
class WatchlistAlternativeTitleTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
APP.reset_runtime(wait=True)
|
||||
APP.initialize_runtime(start_workers=False)
|
||||
@@ -629,16 +629,13 @@ class WatchlistAniListTests(unittest.TestCase):
|
||||
with self.watchlist._connect() as conn:
|
||||
conn.execute("DELETE FROM watchlist")
|
||||
|
||||
def test_watchlist_schema_includes_anilist_columns(self):
|
||||
def test_watchlist_schema_includes_alternative_title_column(self):
|
||||
with self.watchlist._connect() as conn:
|
||||
columns = {row["name"] for row in conn.execute("PRAGMA table_info(watchlist)").fetchall()}
|
||||
|
||||
self.assertIn("anilist_id", columns)
|
||||
self.assertIn("anilist_title", columns)
|
||||
self.assertIn("anilist_site_url", columns)
|
||||
self.assertIn("alternative_titles_json", columns)
|
||||
|
||||
def test_refresh_caches_anilist_alternative_titles(self):
|
||||
def test_refresh_caches_english_anidb_alternative_titles(self):
|
||||
self.watchlist.add({"show_id": "show-1", "title": "Attack on Titan", "category": "watching"})
|
||||
|
||||
with mock.patch.object(
|
||||
@@ -651,29 +648,26 @@ class WatchlistAniListTests(unittest.TestCase):
|
||||
return_value={"route": "attack-on-titan", "title": "Attack on Titan", "episodes": 2, "status": "Finished"},
|
||||
), mock.patch.object(
|
||||
APP,
|
||||
"resolve_anilist_media",
|
||||
return_value={
|
||||
"id": 16498,
|
||||
"siteUrl": "https://anilist.co/anime/16498",
|
||||
"title": {
|
||||
"romaji": "Shingeki no Kyojin",
|
||||
"english": "Attack on Titan",
|
||||
"native": "進撃の巨人",
|
||||
"userPreferred": "Attack on Titan",
|
||||
},
|
||||
"synonyms": ["AoT"],
|
||||
},
|
||||
"resolve_anidb_aid",
|
||||
return_value={"aid": "16498", "title": "Attack on Titan"},
|
||||
), mock.patch.object(
|
||||
APP,
|
||||
"get_cached_anidb_titles",
|
||||
return_value=[
|
||||
{"aid": "16498", "title": "Attack on Titan", "type": "official", "lang": "en", "normalized_title": "attack on titan"},
|
||||
{"aid": "16498", "title": "AoT", "type": "syn", "lang": "en", "normalized_title": "aot"},
|
||||
{"aid": "16498", "title": "Shingeki no Kyojin", "type": "official", "lang": "x-jat", "normalized_title": "shingeki no kyojin"},
|
||||
{"aid": "16498", "title": "Attack Titan", "type": "short", "lang": "en", "normalized_title": "attack titan"},
|
||||
],
|
||||
):
|
||||
item = self.watchlist.refresh("show-1", include_thumbnail=False)
|
||||
|
||||
self.assertEqual(item["anilist_id"], 16498)
|
||||
self.assertEqual(item["anilist_site_url"], "https://anilist.co/anime/16498")
|
||||
self.assertEqual(item["anidb_aid"], "16498")
|
||||
self.assertEqual(
|
||||
item["alternative_titles"],
|
||||
[
|
||||
{"label": "Romaji", "value": "Shingeki no Kyojin"},
|
||||
{"label": "Native", "value": "進撃の巨人"},
|
||||
{"label": "Synonym", "value": "AoT"},
|
||||
{"label": "English", "value": "AoT"},
|
||||
{"label": "English", "value": "Attack Titan"},
|
||||
],
|
||||
)
|
||||
self.assertTrue(item["has_alternative_titles"])
|
||||
@@ -1841,7 +1835,7 @@ class TemplateHelperTests(unittest.TestCase):
|
||||
self.assertIn("Alternative titles", APP.WATCHLIST_HTML)
|
||||
self.assertIn('class="ghost alt-titles-toggle"', APP.WATCHLIST_HTML)
|
||||
self.assertIn('altTitlesPanel.classList.toggle("open")', APP.WATCHLIST_HTML)
|
||||
self.assertIn("AniList alternative titles were not available for this show.", APP.WATCHLIST_HTML)
|
||||
self.assertIn("AniDB English alternative titles were not available for this show.", 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