本文整理汇总了Python中myjobs.tests.factories.UserFactory.get_full_name方法的典型用法代码示例。如果您正苦于以下问题:Python UserFactory.get_full_name方法的具体用法?Python UserFactory.get_full_name怎么用?Python UserFactory.get_full_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类myjobs.tests.factories.UserFactory
的用法示例。
在下文中一共展示了UserFactory.get_full_name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: InvitationModelTests
# 需要导入模块: from myjobs.tests.factories import UserFactory [as 别名]
# 或者: from myjobs.tests.factories.UserFactory import get_full_name [as 别名]
#.........这里部分代码省略.........
'company': company.pk})
self.assertEqual(len(mail.outbox), 1)
email = mail.outbox.pop()
self.assertTrue('invitation' in email.subject)
self.assertEqual(email.from_email, '[email protected]')
self.assertTrue(self.admin.email in email.body)
self.assertTrue(company.name in email.body)
body = BeautifulSoup(email.body)
self.assertEqual(body.select('a')[0].attrs['href'],
'https://secure.my.jobs' + reverse('home'))
return body
def test_invitation_emails_verified_user(self):
"""
Invitations to verified users don't contain activation links. It should
be sufficient to rely on the assertions that companyuser_invitation
makes and then assert that the only anchor in the email body is a
login link.
"""
company = CompanyFactory()
user = UserFactory(email='[email protected]',
is_verified=True)
body = self.companyuser_invitation(user, company)
self.assertEqual(len(body.select('a')), 1)
def test_invitation_emails_unverified_user(self):
"""
Invitations to unverified users should contain activation links, in
addition to the information that companyuser_invitation tests for.
"""
company = CompanyFactory()
user = UserFactory(email='[email protected]',
is_verified=False)
body = self.companyuser_invitation(user, company)
ap = ActivationProfile.objects.get(email=user.email)
# There should be two anchors present, one of which was tested for in
# companyuser_invitation...
self.assertEqual(len(body.select('a')), 2)
# ...and the remaining anchor should be an activation link.
expected_activation_href = 'https://secure.my.jobs%s?verify=%s' % (
reverse('invitation_activate', args=[ap.activation_key]),
user.user_guid)
activation_href = body.select('a')[1].attrs['href']
self.assertEqual(activation_href, expected_activation_href)
self.client.logout()
# Test the activation link from the email.
self.client.get(activation_href)
# If it was a valid link, the current user should now be verified.
user = User.objects.get(pk=user.pk)
self.assertTrue(user.is_verified)
def test_invitation_emails_new_user(self):
self.assertEqual(len(mail.outbox), 0)
Invitation(invitee_email='[email protected]',
inviting_user=self.admin).save()
self.assertEqual(len(mail.outbox), 1)
user = User.objects.get(email='[email protected]')
self.assertTrue(user.in_reserve)
self.assertFalse(user.is_verified)
email = mail.outbox.pop()
self.assertTrue('invitation' in email.subject)
self.assertEqual(email.from_email, '[email protected]')
self.assertTrue(self.admin.email in email.body)
ap = ActivationProfile.objects.get(email=user.email)
body = BeautifulSoup(email.body)
activation_href = body.select('a')[0].attrs['href']
activation_href = activation_href.replace('https://secure.my.jobs', '')
self.assertEqual(activation_href.split('?')[0],
reverse('invitation_activate',
args=[ap.activation_key]))
self.client.logout()
response = self.client.get(activation_href)
self.assertTrue('Your temporary password is ' in response.content)
user = User.objects.get(pk=user.pk)
self.assertFalse(user.in_reserve)
self.assertTrue(user.is_verified)
def test_invitation_email_with_name(self):
PrimaryNameFactory(user=self.admin)
Invitation(invitee_email='[email protected]',
inviting_user=self.admin).save()
email = mail.outbox.pop()
self.assertTrue(self.admin.get_full_name() in email.body)