Add GET /movies/{id}/recommendations
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
Ingestion already stored movie_recommendations edges from TMDb's recommendations list (linking only to movies already ingested into Aurora, per the never-fabricate-a-stub rule), but nothing exposed them. Adds the repository lookup, service assembly, and route to read them back in ranked order. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
73488a0d80
commit
4af4ba40ef
@@ -5,6 +5,7 @@ against PostgreSQL."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import uuid
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
@@ -148,3 +149,38 @@ async def test_movie_detail_surfaces_company_logo_path(db_session: AsyncSession)
|
||||
roadshow = next(c for c in detail.companies if c.name == "Village Roadshow Pictures")
|
||||
assert roadshow.logo_path is not None
|
||||
assert roadshow.logo_path.endswith("/village-roadshow-logo.png")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_movie_recommendations_only_include_already_ingested_movies(
|
||||
db_session: AsyncSession,
|
||||
):
|
||||
"""TMDb's recommendations list can reference movies Aurora hasn't
|
||||
ingested yet; ingest_movie must link only the ones it can resolve by
|
||||
external id (section 15: never fabricate a stub for an unseen entity),
|
||||
and GET .../recommendations must return them in TMDb's ranked order."""
|
||||
|
||||
sequel_payload = {**FAKE_MOVIE, "id": 604, "title": "The Matrix Reloaded"}
|
||||
await ingest_movie(db_session, FakeTMDbProvider(sequel_payload), "604")
|
||||
await db_session.flush()
|
||||
|
||||
movie_with_recs = {
|
||||
**FAKE_MOVIE,
|
||||
"recommendations": {"results": [{"id": 604}, {"id": 999999}]},
|
||||
}
|
||||
movie_id = await ingest_movie(db_session, FakeTMDbProvider(movie_with_recs), "603")
|
||||
await db_session.commit()
|
||||
|
||||
recs = await movie_service.get_movie_recommendations(
|
||||
db_session, aurora_id("movie", str(movie_id))
|
||||
)
|
||||
|
||||
assert [r.title for r in recs.recommendations] == ["The Matrix Reloaded"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_movie_recommendations_not_found_for_unknown_movie(db_session: AsyncSession):
|
||||
with pytest.raises(movie_service.MovieNotFoundError):
|
||||
await movie_service.get_movie_recommendations(
|
||||
db_session, aurora_id("movie", str(uuid.uuid4()))
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user