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
Keywords were ingested and shown read-only on detail pages, but had no
directory (GET /keywords) or filter param -- the same gap genres had
before today. Mirrors the genre browse pattern exactly: repository,
service, route, plus a `keyword` filter on GET /movies and GET /series.
Alternate/translated titles ("Also Known As") were normalized down to
bare title strings and never written to MovieAlternateTitle/
SeriesAlternateTitle at all. Normalizer now captures country_code + type
per TMDb's actual shape; ingestion writes them; movie/series detail now
expose an alternate_titles list.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
102 lines
3.5 KiB
Python
102 lines
3.5 KiB
Python
"""Integration tests for alternate/translated titles ("Also Known As"):
|
|
MovieAlternateTitle/SeriesAlternateTitle rows were ingested nowhere -- the
|
|
normalizer flattened TMDb's alternative_titles entries down to bare title
|
|
strings, discarding country_code/type, and nothing ever wrote them to the
|
|
DB or exposed them via the API. Mirrors test_release_dates.py's fake
|
|
provider pattern."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
from sqlalchemy import select
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.core.ids import aurora_id
|
|
from app.models.movie import MovieAlternateTitle
|
|
from app.models.tv import SeriesAlternateTitle
|
|
from app.services import movie_service, tv_service
|
|
from app.services.ingestion.movie_ingestion import ingest_movie
|
|
from app.services.ingestion.series_ingestion import ingest_series
|
|
from tests.integration.test_release_dates import FakeTMDbProvider
|
|
from tests.unit.test_normalizer import FAKE_MOVIE, FAKE_SERIES
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_ingest_movie_stores_alternate_titles(db_session: AsyncSession):
|
|
movie_id = await ingest_movie(db_session, FakeTMDbProvider(movie_payload=FAKE_MOVIE), "603")
|
|
await db_session.commit()
|
|
|
|
rows = (
|
|
(
|
|
await db_session.execute(
|
|
select(MovieAlternateTitle).where(MovieAlternateTitle.movie_id == movie_id)
|
|
)
|
|
)
|
|
.scalars()
|
|
.all()
|
|
)
|
|
assert len(rows) == 1
|
|
assert rows[0].title == "Matrix"
|
|
assert rows[0].country_code == "US"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_ingest_movie_reingestion_replaces_alternate_titles(db_session: AsyncSession):
|
|
provider = FakeTMDbProvider(movie_payload=FAKE_MOVIE)
|
|
movie_id = await ingest_movie(db_session, provider, "603")
|
|
await db_session.commit()
|
|
await ingest_movie(db_session, provider, "603")
|
|
await db_session.commit()
|
|
|
|
rows = (
|
|
(
|
|
await db_session.execute(
|
|
select(MovieAlternateTitle).where(MovieAlternateTitle.movie_id == movie_id)
|
|
)
|
|
)
|
|
.scalars()
|
|
.all()
|
|
)
|
|
assert len(rows) == 1
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_movie_detail_surfaces_alternate_titles(db_session: AsyncSession):
|
|
movie_id = await ingest_movie(db_session, FakeTMDbProvider(movie_payload=FAKE_MOVIE), "603")
|
|
await db_session.commit()
|
|
|
|
detail = await movie_service.get_movie_detail(db_session, aurora_id("movie", str(movie_id)))
|
|
|
|
assert len(detail.alternate_titles) == 1
|
|
assert detail.alternate_titles[0].title == "Matrix"
|
|
assert detail.alternate_titles[0].country_code == "US"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_ingest_series_stores_alternate_titles(db_session: AsyncSession):
|
|
series_id = await ingest_series(db_session, FakeTMDbProvider(series_payload=FAKE_SERIES), "1396")
|
|
await db_session.commit()
|
|
|
|
rows = (
|
|
(
|
|
await db_session.execute(
|
|
select(SeriesAlternateTitle).where(SeriesAlternateTitle.series_id == series_id)
|
|
)
|
|
)
|
|
.scalars()
|
|
.all()
|
|
)
|
|
assert len(rows) == 1
|
|
assert rows[0].title == "Breaking Bad"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_series_detail_surfaces_alternate_titles(db_session: AsyncSession):
|
|
series_id = await ingest_series(db_session, FakeTMDbProvider(series_payload=FAKE_SERIES), "1396")
|
|
await db_session.commit()
|
|
|
|
detail = await tv_service.get_series_detail(db_session, aurora_id("series", str(series_id)))
|
|
|
|
assert len(detail.alternate_titles) == 1
|
|
assert detail.alternate_titles[0].title == "Breaking Bad"
|