PlexLibrary, PlexShow, PlexSeason, PlexItem, PlexPerson, PlexCollection, PlexState, PlexLink, PlexPlaylist and PlexPlaylistItem leave app/models.py for app/plex/models.py; app.tables registers them. Every import is re-pointed; no schema change.
32 lines
1.3 KiB
Python
32 lines
1.3 KiB
Python
"""Plex card serializers (app.plex.cards) — pure model->dict projections, no DB needed.
|
|
|
|
Movie/show cards now also emit `art` (the wide backdrop, for a Discover rail's landscape tile
|
|
and the crossfading hero), but ONLY when the item actually has an `art_key` — otherwise the URL would
|
|
resolve to a blank image on every card that tried to use it, so it must be null and let the client fall
|
|
back to the poster."""
|
|
|
|
from app.plex.models import PlexItem, PlexShow
|
|
from app.plex.cards import movie_card, show_card
|
|
|
|
|
|
def test_movie_card_emits_art_when_art_key_present():
|
|
it = PlexItem(rating_key="m1", kind="movie", title="M", year=2020, art_key="/library/art/1")
|
|
card = movie_card(it, None, lang="en")
|
|
assert card["thumb"] == "/api/plex/image/m1"
|
|
assert card["art"] == "/api/plex/image/m1?variant=art"
|
|
|
|
|
|
def test_movie_card_art_is_none_without_art_key():
|
|
it = PlexItem(rating_key="m2", kind="movie", title="M2")
|
|
assert movie_card(it, None, lang="en")["art"] is None
|
|
|
|
|
|
def test_show_card_emits_art_when_art_key_present():
|
|
sh = PlexShow(rating_key="s1", title="S", art_key="/library/art/2")
|
|
assert show_card(sh, lang="en")["art"] == "/api/plex/image/s1?variant=art"
|
|
|
|
|
|
def test_show_card_art_is_none_without_art_key():
|
|
sh = PlexShow(rating_key="s2", title="S2")
|
|
assert show_card(sh, lang="en")["art"] is None
|