Add series endpoint parity: /credits, /images, /videos
CI / lint (push) Canceled after 0s
CI / typecheck (push) Canceled after 0s
CI / unit-tests (push) Canceled after 0s
CI / integration-tests (push) Canceled after 0s
CI / container-build (push) Canceled after 0s
CI / dependency-audit (push) Canceled after 0s

Movies have separate /credits, /images, /videos sub-endpoints; series
only had /seasons. Adds the matching three for series, reusing the
same cast/crew/creators three-way split series detail already does
(extracted into _split_series_credits so both share it).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
NixReaper
2026-09-05 09:52:08 -05:00
co-authored by Claude Sonnet 5
parent 6956bf7406
commit 74adcf77bc
5 changed files with 184 additions and 5 deletions
@@ -5,6 +5,7 @@ path against PostgreSQL."""
from __future__ import annotations
import uuid
from typing import Any
import pytest
@@ -140,3 +141,76 @@ async def test_series_detail_surfaces_network_logo_path(db_session: AsyncSession
gran_via = next(c for c in detail.companies if c.name == "Gran Via Productions")
assert gran_via.logo_path is None
@pytest.mark.asyncio
async def test_get_series_credits_separates_cast_crew_and_creators(db_session: AsyncSession):
provider = FakeTMDbSeriesProvider(FAKE_SERIES, FAKE_SEASON)
series_id = await ingest_series(db_session, provider, "1396")
await db_session.commit()
credits_out = await tv_service.get_series_credits(
db_session, aurora_id("series", str(series_id))
)
assert [c.person.name for c in credits_out.cast] == ["Bryan Cranston"]
assert credits_out.cast[0].character == "Walter White"
assert credits_out.crew == []
assert [c.person.name for c in credits_out.creators] == ["Vince Gilligan"]
@pytest.mark.asyncio
async def test_get_series_images_returns_poster_and_backdrop(db_session: AsyncSession):
provider = FakeTMDbSeriesProvider(FAKE_SERIES, FAKE_SEASON)
series_id = await ingest_series(db_session, provider, "1396")
await db_session.commit()
images_out = await tv_service.get_series_images(
db_session, aurora_id("series", str(series_id))
)
assert len(images_out.images.posters) == 1
assert images_out.images.posters[0].url.endswith("/poster.jpg")
assert len(images_out.images.backdrops) == 1
@pytest.mark.asyncio
async def test_get_series_videos_returns_normalized_videos(db_session: AsyncSession):
payload = {
**FAKE_SERIES,
"videos": {
"results": [
{
"id": "abc123",
"site": "YouTube",
"key": "dQw4w9WgXcQ",
"type": "Trailer",
"official": True,
"iso_639_1": "en",
"iso_3166_1": "US",
}
]
},
}
provider = FakeTMDbSeriesProvider(payload, FAKE_SEASON)
series_id = await ingest_series(db_session, provider, "1396")
await db_session.commit()
videos_out = await tv_service.get_series_videos(
db_session, aurora_id("series", str(series_id))
)
assert len(videos_out.videos) == 1
assert videos_out.videos[0].site == "YouTube"
assert videos_out.videos[0].is_official is True
@pytest.mark.asyncio
async def test_series_sub_endpoints_raise_not_found_for_unknown_series(db_session: AsyncSession):
unknown_id = aurora_id("series", str(uuid.uuid4()))
with pytest.raises(tv_service.SeriesNotFoundError):
await tv_service.get_series_credits(db_session, unknown_id)
with pytest.raises(tv_service.SeriesNotFoundError):
await tv_service.get_series_images(db_session, unknown_id)
with pytest.raises(tv_service.SeriesNotFoundError):
await tv_service.get_series_videos(db_session, unknown_id)