本文整理汇总了Python中registration.users.UserModel.check_password方法的典型用法代码示例。如果您正苦于以下问题:Python UserModel.check_password方法的具体用法?Python UserModel.check_password怎么用?Python UserModel.check_password使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类registration.users.UserModel
的用法示例。
在下文中一共展示了UserModel.check_password方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_registration_no_sites
# 需要导入模块: from registration.users import UserModel [as 别名]
# 或者: from registration.users.UserModel import check_password [as 别名]
def test_registration_no_sites(self):
"""
Registration still functions properly when
``django.contrib.sites`` is not installed; the fallback will
be a ``RequestSite`` instance.
"""
Site._meta.installed = False
resp = self.client.post(reverse('registration_register'),
data={'username': 'bob',
'email': '[email protected]',
'password1': 'secret',
'password2': 'secret'})
self.assertEqual(302, resp.status_code)
new_user = UserModel().objects.get(username='bob')
self.failUnless(new_user.check_password('secret'))
self.assertEqual(new_user.email, '[email protected]')
self.failIf(new_user.is_active)
self.assertEqual(RegistrationProfile.objects.count(), 1)
self.assertEqual(len(mail.outbox), 1)
Site._meta.installed = True
示例2: test_registration
# 需要导入模块: from registration.users import UserModel [as 别名]
# 或者: from registration.users.UserModel import check_password [as 别名]
def test_registration(self):
"""
Registration creates a new inactive account and a new profile
with activation key, populates the correct account data and
sends an activation email.
"""
resp = self.client.post(reverse('registration_register'),
data={'username': 'bob',
'email': '[email protected]',
'password1': 'secret',
'password2': 'secret'})
self.assertRedirects(resp, reverse('registration_complete'))
new_user = UserModel().objects.get(username='bob')
self.failUnless(new_user.check_password('secret'))
self.assertEqual(new_user.email, '[email protected]')
# New user must not be active.
self.failIf(new_user.is_active)
# A registration profile was created, and an activation email
# was sent.
self.assertEqual(RegistrationProfile.objects.count(), 1)
self.assertEqual(len(mail.outbox), 1)
示例3: test_registration
# 需要导入模块: from registration.users import UserModel [as 别名]
# 或者: from registration.users.UserModel import check_password [as 别名]
def test_registration(self):
"""
Registration creates a new inactive account and a new profile
with activation key, populates the correct account data and
sends an activation email.
"""
resp = self.client.post(
reverse("registration_register"),
data={"username": "bob", "email": "[email protected]", "password1": "secret", "password2": "secret"},
)
self.assertRedirects(resp, reverse("registration_complete"))
new_user = UserModel().objects.get(username="bob")
self.failUnless(new_user.check_password("secret"))
self.assertEqual(new_user.email, "[email protected]")
# New user must not be active.
self.failIf(new_user.is_active)
# A registration profile was created, and an activation email
# was sent.
self.assertEqual(RegistrationProfile.objects.count(), 1)
self.assertEqual(len(mail.outbox), 1)
示例4: test_profile_retrieval
# 需要导入模块: from registration.users import UserModel [as 别名]
# 或者: from registration.users.UserModel import check_password [as 别名]
def test_profile_retrieval(self):
# Testing User Information Retrieval for Login
new_user = UserModel().objects.create_user(**self.user_info)
existing_user = UserModel().objects.get(username='docemployee')
self.failUnless(existing_user.check_password('letstravel'))
self.assertEqual(existing_user.email, '[email protected]')
self.failUnless(existing_user.is_active)
示例5: test_registration_no_sites
# 需要导入模块: from registration.users import UserModel [as 别名]
# 或者: from registration.users.UserModel import check_password [as 别名]
def test_registration_no_sites(self):
"""
Registration still functions properly when
``django.contrib.sites`` is not installed; the fallback will
be a ``RequestSite`` instance.
"""
resp = self.client.post(
reverse("registration_register"),
data={"username": "bob", "email": "[email protected]", "password1": "secret", "password2": "secret"},
)
self.assertEqual(302, resp.status_code)
new_user = UserModel().objects.get(username="bob")
self.failUnless(new_user.check_password("secret"))
self.assertEqual(new_user.email, "[email protected]")
self.failIf(new_user.is_active)
self.assertEqual(RegistrationProfile.objects.count(), 1)
self.assertEqual(len(mail.outbox), 1)
示例6: test_registration
# 需要导入模块: from registration.users import UserModel [as 别名]
# 或者: from registration.users.UserModel import check_password [as 别名]
def test_registration(self):
"""
Registration creates a new account and logs the user in.
"""
resp = self.client.post(reverse('registration_register'),
data={'username': 'bob',
'email': '[email protected]',
'password1': 'secret',
'password2': 'secret'})
new_user = UserModel().objects.get(username='bob')
self.assertEqual(302, resp.status_code)
self.failUnless(reverse('registration_complete') in resp['Location'])
self.failUnless(new_user.check_password('secret'))
self.assertEqual(new_user.email, '[email protected]')
# New user must be active.
self.failUnless(new_user.is_active)
# New user must be logged in.
resp = self.client.get(reverse('registration_register'))
self.failUnless(resp.context['user'].is_authenticated())
示例7: test_registration
# 需要导入模块: from registration.users import UserModel [as 别名]
# 或者: from registration.users.UserModel import check_password [as 别名]
def test_registration(self):
"""
Registration creates a new account and logs the user in.
"""
resp = self.client.post(reverse('registration_register'),
data={'username': 'bob',
'email': '[email protected]',
'password1': 'secret',
'password2': 'secret'})
new_user = UserModel().objects.get(username='bob')
self.assertEqual(302, resp.status_code)
self.assertIn(getattr(settings, 'SIMPLE_BACKEND_REDIRECT_URL', '/'),
resp['Location'])
self.assertTrue(new_user.check_password('secret'))
self.assertEqual(new_user.email, '[email protected]')
# New user must be active.
self.assertTrue(new_user.is_active)
# New user must be logged in.
resp = self.client.get(reverse('registration_register'), follow=True)
self.assertTrue(resp.context['user'].is_authenticated)