diff options
Diffstat (limited to 'tests/auth_tests/test_management.py')
| -rw-r--r-- | tests/auth_tests/test_management.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/auth_tests/test_management.py b/tests/auth_tests/test_management.py index 87f2ae1790..d0a91f3261 100644 --- a/tests/auth_tests/test_management.py +++ b/tests/auth_tests/test_management.py @@ -6,7 +6,7 @@ from io import StringIO from unittest import mock from django.apps import apps -from django.contrib.auth import management +from django.contrib.auth import get_permission_codename, management from django.contrib.auth.management import ( create_permissions, get_default_username, ) @@ -23,6 +23,7 @@ from django.utils.translation import gettext_lazy as _ from .models import ( CustomUser, CustomUserNonUniqueUsername, CustomUserWithFK, Email, + UserProxy, ) MOCK_INPUT_KEY_TO_PROMPTS = { @@ -985,3 +986,18 @@ class CreatePermissionsTests(TestCase): ContentType.objects.filter(app_label='auth', model='group').delete() # This fails with a foreign key constraint without the fix. create_permissions(apps.get_app_config('auth'), interactive=False, verbosity=0) + + def test_permission_with_proxy_content_type_created(self): + """ + A proxy model's permissions use its own content type rather than the + content type of the concrete model. + """ + opts = UserProxy._meta + codename = get_permission_codename('add', opts) + self.assertTrue( + Permission.objects.filter( + content_type__model=opts.model_name, + content_type__app_label=opts.app_label, + codename=codename, + ).exists() + ) |
