summaryrefslogtreecommitdiff
path: root/tests/auth_tests
diff options
context:
space:
mode:
authorDavid Wobrock <david.wobrock@gmail.com>2022-12-23 18:16:05 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-12-24 11:58:33 +0100
commit5aaad5f39c67591ba3d60c57ffa03fac12965f26 (patch)
treece1bb1c9f58f13c9a2fb68b762ca2c5e7417261f /tests/auth_tests
parent0bd2c0c9015b53c41394a1c0989afbfd94dc2830 (diff)
downloaddjango-5aaad5f39c67591ba3d60c57ffa03fac12965f26.tar.gz
Fixed #34165 -- Made permissions creation respect the "using" parameter.
Diffstat (limited to 'tests/auth_tests')
-rw-r--r--tests/auth_tests/test_management.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/auth_tests/test_management.py b/tests/auth_tests/test_management.py
index f567fd0dc1..7e0a301238 100644
--- a/tests/auth_tests/test_management.py
+++ b/tests/auth_tests/test_management.py
@@ -1485,3 +1485,22 @@ class CreatePermissionsTests(TestCase):
codename=codename,
).exists()
)
+
+
+class DefaultDBRouter:
+ """Route all writes to default."""
+
+ def db_for_write(self, model, **hints):
+ return "default"
+
+
+@override_settings(DATABASE_ROUTERS=[DefaultDBRouter()])
+class CreatePermissionsMultipleDatabasesTests(TestCase):
+ databases = {"default", "other"}
+
+ def test_set_permissions_fk_to_using_parameter(self):
+ Permission.objects.using("other").delete()
+ with self.assertNumQueries(6, using="other") as captured_queries:
+ create_permissions(apps.get_app_config("auth"), verbosity=0, using="other")
+ self.assertIn("INSERT INTO", captured_queries[-1]["sql"].upper())
+ self.assertGreater(Permission.objects.using("other").count(), 0)