"""Postfix/Dovecot read these tables directly, so their names must never change.""" import pytest from django.core.management import call_command from django.db import connection SCHEMA = { "dpdapi_domain": {"id", "created", "updated", "name"}, "dpdapi_alias": {"id", "created", "updated", "source", "destination", "active", "domain_id"}, "dpdapi_user": {"id", "created", "updated", "email", "password", "domain_id"}, } @pytest.mark.django_db @pytest.mark.parametrize(("table", "columns"), SCHEMA.items()) def test_tables_and_columns(table, columns): with connection.cursor() as cursor: description = connection.introspection.get_table_description(cursor, table) assert {c.name for c in description} == columns @pytest.mark.django_db def test_no_pending_migrations(): call_command("makemigrations", "dpdapi", "--check", "--dry-run")