当前位置: 首页>>代码示例>>Python>>正文


Python UserFactory.get_full_name方法代码示例

本文整理汇总了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)
开发者ID:kepinae,项目名称:MyJobs,代码行数:104,代码来源:test_models.py


注:本文中的myjobs.tests.factories.UserFactory.get_full_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。