mirror of
https://github.com/django/django.git
synced 2025-10-26 23:26:08 +00:00
Removed custom profile model functionality as per deprecation TL.
This commit is contained in:
@@ -1,46 +1,9 @@
|
||||
import warnings
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.models import (Group, User, SiteProfileNotAvailable,
|
||||
UserManager)
|
||||
from django.contrib.auth.models import (Group, User, UserManager)
|
||||
from django.contrib.auth.tests.utils import skipIfCustomUser
|
||||
from django.db.models.signals import post_save
|
||||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
from django.utils import six
|
||||
|
||||
|
||||
@skipIfCustomUser
|
||||
@override_settings(USE_TZ=False, AUTH_PROFILE_MODULE='')
|
||||
class ProfileTestCase(TestCase):
|
||||
|
||||
def test_site_profile_not_available(self):
|
||||
user = User.objects.create(username='testclient')
|
||||
|
||||
# calling get_profile without AUTH_PROFILE_MODULE set
|
||||
del settings.AUTH_PROFILE_MODULE
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", DeprecationWarning)
|
||||
with six.assertRaisesRegex(self, SiteProfileNotAvailable,
|
||||
"You need to set AUTH_PROFILE_MODULE in your project"):
|
||||
user.get_profile()
|
||||
|
||||
# Bad syntax in AUTH_PROFILE_MODULE:
|
||||
settings.AUTH_PROFILE_MODULE = 'foobar'
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", DeprecationWarning)
|
||||
with six.assertRaisesRegex(self, SiteProfileNotAvailable,
|
||||
"app_label and model_name should be separated by a dot"):
|
||||
user.get_profile()
|
||||
|
||||
# module that doesn't exist
|
||||
settings.AUTH_PROFILE_MODULE = 'foo.bar'
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", DeprecationWarning)
|
||||
with six.assertRaisesRegex(self, SiteProfileNotAvailable,
|
||||
"Unable to load the profile model"):
|
||||
user.get_profile()
|
||||
|
||||
|
||||
@skipIfCustomUser
|
||||
|
||||
Reference in New Issue
Block a user