From 29fffc8919517e7047a6c171fdad66f6cf2e4552 Mon Sep 17 00:00:00 2001 From: NixReaper Date: Sat, 5 Sep 2026 20:12:03 -0500 Subject: [PATCH] Fix test fixtures: two movies can't share FAKE_MOVIE's embedded video FAKE_MOVIE carries a fixed provider_video_id ("abc123"); two different fake movies both spreading it unmodified and getting ingested in the same test collide on the real uq_video_provider_source unique constraint (a video id belongs to exactly one entity). Found by actually running the tests against Postgres on the devbox -- these paths were only ever collect-only'd locally before now (no local DB). Affected: test_movie_recommendations_only_include_already_ingested_movies and test_ingest_collection_only_links_already_ingested_movies, both of which ingest two FAKE_MOVIE-derived movies in one test. Fixed by overriding videos to empty on the second movie in each. Co-Authored-By: Claude Sonnet 5 --- tests/integration/test_collection_ingestion.py | 10 +++++++++- tests/integration/test_movie_ingestion.py | 12 +++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/tests/integration/test_collection_ingestion.py b/tests/integration/test_collection_ingestion.py index cb577d7..39d3191 100644 --- a/tests/integration/test_collection_ingestion.py +++ b/tests/integration/test_collection_ingestion.py @@ -57,10 +57,18 @@ async def test_ingest_collection_only_links_already_ingested_movies(db_session: already knows about, in release-date order, never fabricate a stub for the other two (section 15).""" + # 604's videos overridden to empty: FAKE_MOVIE's embedded video has a + # fixed provider_video_id, and two different movies both ingesting it + # would collide on the real uq_video_provider_source unique constraint. provider = FakeTMDbCollectionProvider( movie_payloads={ "603": {**FAKE_MOVIE, "id": 603, "title": "The Matrix"}, - "604": {**FAKE_MOVIE, "id": 604, "title": "The Matrix Reloaded"}, + "604": { + **FAKE_MOVIE, + "id": 604, + "title": "The Matrix Reloaded", + "videos": {"results": []}, + }, }, collection_payload=FAKE_COLLECTION, ) diff --git a/tests/integration/test_movie_ingestion.py b/tests/integration/test_movie_ingestion.py index 47f604d..4a37aa1 100644 --- a/tests/integration/test_movie_ingestion.py +++ b/tests/integration/test_movie_ingestion.py @@ -188,7 +188,17 @@ async def test_movie_recommendations_only_include_already_ingested_movies( 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"} + # videos overridden to empty: FAKE_MOVIE's embedded video has a fixed + # provider_video_id, and two different movies both ingesting it would + # collide on the real uq_video_provider_source unique constraint -- + # a video id is only ever attached to one entity, unlike genres/companies + # which are legitimately shared. + sequel_payload = { + **FAKE_MOVIE, + "id": 604, + "title": "The Matrix Reloaded", + "videos": {"results": []}, + } await ingest_movie(db_session, FakeTMDbProvider(sequel_payload), "604") await db_session.flush()