Fix test fixture: seed countries before companies referencing them
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

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 <[email protected]>
This commit is contained in:
NixReaper
2026-09-05 19:15:09 -05:00
co-authored by Claude Sonnet 5
parent 92b0f4e077
commit 4cf3556433
+3 -1
View File
@@ -12,7 +12,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
from app.models.enums import CompanyType from app.models.enums import CompanyType
from app.repositories.provider_repository import get_or_create_provider 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 from app.services import company_service
_COMPANIES = [ _COMPANIES = [
@@ -25,6 +25,8 @@ _COMPANIES = [
async def _seed_companies(db_session: AsyncSession) -> None: async def _seed_companies(db_session: AsyncSession) -> None:
provider = await get_or_create_provider(db_session, "tmdb", "TMDB") 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: for external_id, name, company_type, country in _COMPANIES:
await get_or_create_company( await get_or_create_company(
db_session, db_session,