diff options
| author | David Sanders <shang.xiao.sanders@gmail.com> | 2025-09-15 03:35:53 +1000 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2025-09-15 21:17:18 +0200 |
| commit | 6e89271a8507fe272d11814975500a1b40303a04 (patch) | |
| tree | f33f750b6d292f3c25a3daa21db394e32cf296fb /tests/auth_tests/test_management.py | |
| parent | e7740780d0a5cc3123e351d955cc9d9d44dcbd20 (diff) | |
Refs #27489 -- Made RenamePermission() operation respect database.
Regression in f02b49d2f3bf84f5225de920ca510149f1f9f1da.
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
Diffstat (limited to 'tests/auth_tests/test_management.py')
| -rw-r--r-- | tests/auth_tests/test_management.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auth_tests/test_management.py b/tests/auth_tests/test_management.py index 7e8d01cbce..46fe310db2 100644 --- a/tests/auth_tests/test_management.py +++ b/tests/auth_tests/test_management.py @@ -1546,6 +1546,7 @@ class PermissionRenameOperationsTests(TransactionTestCase): "django.contrib.auth", "auth_tests", ] + databases = {"default", "other"} def setUp(self): app_config = apps.get_app_config("auth_tests") @@ -1605,6 +1606,26 @@ class PermissionRenameOperationsTests(TransactionTestCase): Permission.objects.filter(codename=f"{action}_newmodel").exists() ) + def test_permission_rename_other_db(self): + ct = ContentType.objects.using("default").create( + app_label="auth_tests", model="oldmodel" + ) + permission = Permission.objects.using("default").create( + codename="add_oldmodel", + name="Can add old model", + content_type=ct, + ) + # RenamePermission respects the database. + call_command("migrate", "auth_tests", verbosity=0, database="other") + permission.refresh_from_db() + self.assertEqual(permission.codename, "add_oldmodel") + self.assertFalse( + Permission.objects.using("other").filter(codename="add_oldmodel").exists() + ) + self.assertTrue( + Permission.objects.using("other").filter(codename="add_newmodel").exists() + ) + @mock.patch( "django.db.router.allow_migrate_model", return_value=False, |
