Files
chatbot_v3/tests/integration/postgres/test_migrations.py
Ali Zarinkolah 80ed5b1577 test(postgres): allow Testcontainers to override the migration sqlalchemy.url
alembic/env.py previously always overwrote sqlalchemy.url from
Settings().postgres.dsn, which made it impossible for a test fixture to
point Alembic at a Testcontainers-managed database. Now env.py only
sets it when unset, and a new integration suite runs `alembic upgrade
head` against a real Postgres container per ADR-0016 (no create_all()).
2026-08-18 10:21:56 +03:30

24 lines
660 B
Python

import pytest
from sqlalchemy import inspect
from sqlalchemy.ext.asyncio import AsyncEngine
pytestmark = [pytest.mark.integration, pytest.mark.postgres, pytest.mark.asyncio]
EXPECTED_TABLES = {
"tenants",
"api_keys",
"source_files",
"ingestion_jobs",
"ingestion_job_events",
"alembic_version",
}
async def test_migrations_create_schema_from_empty_database(postgres_engine: AsyncEngine) -> None:
async with postgres_engine.connect() as connection:
table_names = await connection.run_sync(
lambda sync_conn: inspect(sync_conn).get_table_names()
)
assert EXPECTED_TABLES.issubset(set(table_names))