"""Plex card serializers (app.plex.cards) — pure model->dict projections, no DB needed. E5 S1: 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.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) 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)["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)["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)["art"] is None