Пример #1
0
        def test_check_custom_user_model(self):
            warnings = checks.check_custom_user_model(HijackAdminConfig)
            self.assertFalse(warnings)

            with self.settings(AUTH_USER_MODEL='my_auth_user_model'):
                warnings = checks.check_custom_user_model(HijackAdminConfig)
                expected_warnings = [
                    Warning(
                        'django-hijack-admin does not work out the box with a custom user model.',
                        hint='Please mix HijackUserAdminMixin into your custom UserAdmin.',
                        obj=settings.AUTH_USER_MODEL,
                        id='hijack_admin.W001',
                    )
                ]
                self.assertEqual(warnings, expected_warnings)
Пример #2
0
        def test_check_custom_user_model(self):
            # Django doesn't re-register admins when using `override_settings`,
            # so we have to do it manually in this test case.
            admin.site.register(get_user_model(), HijackUserAdmin)

            warnings = checks.check_custom_user_model(HijackAdminConfig)
            self.assertFalse(warnings)

            admin.site.unregister(get_user_model())
Пример #3
0
        def test_check_custom_user_model(self):
            # Django doesn't re-register admins when using `override_settings`,
            # so we have to do it manually in this test case.
            admin.site.register(get_user_model(), HijackUserAdmin)

            warnings = checks.check_custom_user_model(HijackAdminConfig)
            self.assertFalse(warnings)

            admin.site.unregister(get_user_model())
        def test_check_custom_user_model_custom_admin(self):
            class CustomAdminSite(admin.AdminSite):
                pass

            _default_site = admin.site
            admin.site = CustomAdminSite()
            admin.autodiscover()

            admin.site.register(get_user_model(), HijackUserAdmin)

            warnings = checks.check_custom_user_model(HijackAdminConfig)
            self.assertFalse(warnings)

            admin.site.unregister(get_user_model())
            admin.site = _default_site
Пример #5
0
        def test_check_custom_user_model_default_admin(self):
            # Django doesn't re-register admins when using `override_settings`,
            # so we have to do it manually in this test case.
            admin.site.register(get_user_model(), UserAdmin)

            warnings = checks.check_custom_user_model(HijackAdminConfig)
            expected_warnings = [
                Warning(
                    'django-hijack-admin does not work out the box with a custom user model.',
                    hint='Please mix HijackUserAdminMixin into your custom UserAdmin.',
                    obj=settings.AUTH_USER_MODEL,
                    id='hijack_admin.W001',
                )
            ]
            self.assertEqual(warnings, expected_warnings)

            admin.site.unregister(get_user_model())
Пример #6
0
        def test_check_custom_user_model_default_admin(self):
            # Django doesn't re-register admins when using `override_settings`,
            # so we have to do it manually in this test case.
            admin.site.register(get_user_model(), UserAdmin)

            warnings = checks.check_custom_user_model(HijackAdminConfig)
            expected_warnings = [
                Warning(
                    'django-hijack-admin does not work out the box with a custom user model.',
                    hint=
                    'Please mix HijackUserAdminMixin into your custom UserAdmin.',
                    obj=settings.AUTH_USER_MODEL,
                    id='hijack_admin.W001',
                )
            ]
            self.assertEqual(warnings, expected_warnings)

            admin.site.unregister(get_user_model())
Пример #7
0
 def test_check_default_user_model(self):
     warnings = checks.check_custom_user_model(HijackAdminConfig)
     self.assertFalse(warnings)
Пример #8
0
 def test_check_default_user_model(self):
     warnings = checks.check_custom_user_model(HijackAdminConfig)
     self.assertFalse(warnings)