15 lines
564 B
Python
15 lines
564 B
Python
"""Catches "edited models.py but forgot the migration"."""
|
|
|
|
from alembic.autogenerate import compare_metadata
|
|
from alembic.migration import MigrationContext
|
|
|
|
from app.db import engine
|
|
from app.models import Base, alembic_compare_type
|
|
|
|
|
|
def test_migrations_match_models(_app_started):
|
|
with engine.connect() as conn:
|
|
ctx = MigrationContext.configure(conn, opts={"compare_type": alembic_compare_type})
|
|
diff = compare_metadata(ctx, Base.metadata)
|
|
assert diff == [], f"Models and migrations differ; run: alembic revision --autogenerate\n{diff}"
|