Add movies/series filmography to company detail
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
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
GET /companies/{id} showed only the company's own info. Adds movies
and series lists (any role: production, distribution, network),
ordered by release/first-air date, read straight off the existing
movie_companies/series_companies junction rows -- no separate sync
needed since those only ever exist as a side effect of ingesting the
movie or series itself.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
606d2532c4
commit
6956bf7406
@@ -0,0 +1,94 @@
|
||||
"""Integration test for company filmography (section 17): GET /companies/{id}
|
||||
listing the movies/series a studio/network has produced, the same pattern
|
||||
collections use for their member movies. Exercised through
|
||||
company_service.get_company_detail against real PostgreSQL."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.core.ids import aurora_id
|
||||
from app.models.company import Company
|
||||
from app.services import company_service
|
||||
from app.services.ingestion.movie_ingestion import ingest_movie
|
||||
from app.services.ingestion.series_ingestion import ingest_series
|
||||
from tests.integration.test_movie_ingestion import FakeTMDbProvider
|
||||
from tests.integration.test_series_ingestion import FakeTMDbSeriesProvider
|
||||
|
||||
_SHARED_STUDIO = {"id": 555, "name": "Shared Studio", "origin_country": "US"}
|
||||
|
||||
|
||||
def _movie_payload(**overrides: Any) -> dict[str, Any]:
|
||||
base = {
|
||||
"id": 9200,
|
||||
"title": "Untitled",
|
||||
"status": "Released",
|
||||
"production_companies": [_SHARED_STUDIO],
|
||||
"release_date": "2020-01-01",
|
||||
}
|
||||
base.update(overrides)
|
||||
return base
|
||||
|
||||
|
||||
def _series_payload(**overrides: Any) -> dict[str, Any]:
|
||||
base = {
|
||||
"id": 9200,
|
||||
"name": "Untitled",
|
||||
"status": "Ended",
|
||||
"production_companies": [_SHARED_STUDIO],
|
||||
"first_air_date": "2020-01-01",
|
||||
}
|
||||
base.update(overrides)
|
||||
return base
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_company_detail_lists_its_movies_and_series_by_release_date(
|
||||
db_session: AsyncSession,
|
||||
):
|
||||
later_movie = _movie_payload(id=9201, title="Studio Movie 1", release_date="2021-01-01")
|
||||
earlier_movie = _movie_payload(id=9202, title="Studio Movie 2", release_date="2019-01-01")
|
||||
show = _series_payload(id=9203, name="Studio Show", first_air_date="2020-06-01")
|
||||
|
||||
await ingest_movie(db_session, FakeTMDbProvider(later_movie), "9201")
|
||||
await ingest_movie(db_session, FakeTMDbProvider(earlier_movie), "9202")
|
||||
await ingest_series(db_session, FakeTMDbSeriesProvider(show, {}), "9203")
|
||||
await db_session.commit()
|
||||
|
||||
company = (
|
||||
await db_session.execute(select(Company).where(Company.name == "Shared Studio"))
|
||||
).scalar_one()
|
||||
|
||||
detail = await company_service.get_company_detail(
|
||||
db_session, aurora_id("company", str(company.id))
|
||||
)
|
||||
|
||||
# Ordered by release date ascending, not ingestion order.
|
||||
assert [m.title for m in detail.movies] == ["Studio Movie 2", "Studio Movie 1"]
|
||||
assert [s.title for s in detail.series] == ["Studio Show"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_company_detail_series_list_is_empty_for_a_movie_only_studio(
|
||||
db_session: AsyncSession,
|
||||
):
|
||||
movie = _movie_payload(
|
||||
id=9204, title="Lone Movie", production_companies=[{"id": 556, "name": "Solo Studio"}]
|
||||
)
|
||||
await ingest_movie(db_session, FakeTMDbProvider(movie), "9204")
|
||||
await db_session.commit()
|
||||
|
||||
company = (
|
||||
await db_session.execute(select(Company).where(Company.name == "Solo Studio"))
|
||||
).scalar_one()
|
||||
|
||||
detail = await company_service.get_company_detail(
|
||||
db_session, aurora_id("company", str(company.id))
|
||||
)
|
||||
|
||||
assert len(detail.movies) == 1
|
||||
assert detail.series == []
|
||||
Reference in New Issue
Block a user