From 4cf35564334f8800cba228e23422f78e2674d11d Mon Sep 17 00:00:00 2001 From: NixReaper Date: Sat, 5 Sep 2026 19:15:09 -0500 Subject: [PATCH] Fix test fixture: seed countries before companies referencing them companies.country_code has a real FK to countries -- real ingestion always calls get_or_create_country first (see _replace_movie_companies), but the company browse test fixture called get_or_create_company directly with a raw country code, violating that FK. Found by actually running the tests against Postgres on the devbox. Co-Authored-By: Claude Sonnet 5 --- tests/integration/test_company_browse.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/integration/test_company_browse.py b/tests/integration/test_company_browse.py index 3493add..13ae30f 100644 --- a/tests/integration/test_company_browse.py +++ b/tests/integration/test_company_browse.py @@ -12,7 +12,7 @@ from sqlalchemy.ext.asyncio import AsyncSession from app.models.enums import CompanyType from app.repositories.provider_repository import get_or_create_provider -from app.repositories.reference_repository import get_or_create_company +from app.repositories.reference_repository import get_or_create_company, get_or_create_country from app.services import company_service _COMPANIES = [ @@ -25,6 +25,8 @@ _COMPANIES = [ async def _seed_companies(db_session: AsyncSession) -> None: provider = await get_or_create_provider(db_session, "tmdb", "TMDB") + for code in {country for _, _, _, country in _COMPANIES}: + await get_or_create_country(db_session, code, code) for external_id, name, company_type, country in _COMPANIES: await get_or_create_company( db_session,