summaryrefslogtreecommitdiff
path: root/tests/migrations
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2025-11-08 15:26:36 -0500
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2025-11-13 10:18:06 +0100
commit1b539ef27e776bd6112e8f22e653feca5279c4fb (patch)
tree3c8b99a28bcc5426eb119b6d52e417fc0c3eb5e1 /tests/migrations
parentabfa4619fb818ff694c22e962a280673e085239e (diff)
Refs #31055 -- Augmented regression tests for database system checks.
We might want to change this in the future but it should be further discussed first.
Diffstat (limited to 'tests/migrations')
-rw-r--r--tests/migrations/test_commands.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py
index b5817081d2..83c5575fd3 100644
--- a/tests/migrations/test_commands.py
+++ b/tests/migrations/test_commands.py
@@ -113,7 +113,7 @@ class MigrateTests(MigrationTestBase):
out = io.StringIO()
call_command("migrate", skip_checks=False, no_color=True, stdout=out)
self.assertIn("Apply all migrations: migrated_app", out.getvalue())
- mocked_check.assert_called_once()
+ mocked_check.assert_called_once_with(databases=["default"])
def test_migrate_with_custom_system_checks(self):
original_checks = registry.registered_checks.copy()
@@ -139,6 +139,25 @@ class MigrateTests(MigrationTestBase):
@override_settings(
INSTALLED_APPS=[
+ "django.contrib.auth",
+ "django.contrib.contenttypes",
+ "migrations.migrations_test_apps.migrated_app",
+ ]
+ )
+ def test_migrate_runs_database_system_checks(self):
+ original_checks = registry.registered_checks.copy()
+ self.addCleanup(setattr, registry, "registered_checks", original_checks)
+
+ out = io.StringIO()
+ mock_check = mock.Mock(return_value=[])
+ register(mock_check, Tags.database)
+
+ call_command("migrate", skip_checks=False, no_color=True, stdout=out)
+ self.assertIn("Apply all migrations: migrated_app", out.getvalue())
+ mock_check.assert_called_once_with(app_configs=None, databases=["default"])
+
+ @override_settings(
+ INSTALLED_APPS=[
"migrations",
"migrations.migrations_test_apps.unmigrated_app_syncdb",
]