test(mediaserver): cover stale tv item id fallback

This commit is contained in:
InfinityPacer
2026-05-09 06:54:39 +08:00
committed by jxxghp
parent bedab9ab92
commit 268414fb11
2 changed files with 211 additions and 6 deletions
+8 -6
View File
@@ -5,12 +5,18 @@ from app.modules.plex.plex import Plex
class PlexImageLookupTest(unittest.TestCase):
def test_get_remote_image_by_id_uses_item_arts_for_children_key(self):
@staticmethod
def _build_plex():
"""构造绕过真实连接的Plex实例,便于单测直接注入plexapi mock。"""
plex = Plex.__new__(Plex)
plex._host = "http://192.168.8.254:32400/"
plex._playhost = None
plex._token = "plex-token"
plex._plex = Mock()
return plex
def test_get_remote_image_by_id_uses_item_arts_for_children_key(self):
plex = self._build_plex()
plex._plex.fetchItems.side_effect = AssertionError("should not use raw fetchItems with /children key")
item = Mock()
@@ -31,11 +37,7 @@ class PlexImageLookupTest(unittest.TestCase):
plex._plex.fetchItem.assert_called_once_with(ekey="/library/metadata/29242/children")
def test_get_remote_image_by_id_falls_back_to_local_art_url(self):
plex = Plex.__new__(Plex)
plex._host = "http://192.168.8.254:32400/"
plex._playhost = None
plex._token = "plex-token"
plex._plex = Mock()
plex = self._build_plex()
item = Mock()
item.TYPE = "show"