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


Python tests.UserProfileFactory类代码示例

本文整理汇总了Python中oneanddone.users.tests.UserProfileFactory的典型用法代码示例。如果您正苦于以下问题:Python UserProfileFactory类的具体用法?Python UserProfileFactory怎么用?Python UserProfileFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了UserProfileFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_object

 def test_get_object(self):
     """
     Return the current user's profile.
     """
     self.request.user = UserProfileFactory.create().user
     self.view.request = self.request
     eq_(self.view.get_object(), self.request.user.profile)
开发者ID:Anmol2307,项目名称:oneanddone,代码行数:7,代码来源:test_views.py

示例2: test_unicode

 def test_unicode(self):
     """
     The string representation of a user should include their
     email address.
     """
     user = UserProfileFactory.create(name='Foo Bar', user__email='[email protected]').user
     eq_(unicode(user), u'Foo Bar ([email protected])')
开发者ID:VarnaSuresh,项目名称:oneanddone,代码行数:7,代码来源:test_models.py

示例3: test_display_name

 def test_display_name(self):
     """
     The display_name attribute should use the name from the user's
     profile.
     """
     user = UserProfileFactory.create(name='Foo Bar').user
     eq_(user.display_name, 'Foo Bar')
开发者ID:VarnaSuresh,项目名称:oneanddone,代码行数:7,代码来源:test_models.py

示例4: test_get_object_existing_username

    def test_get_object_existing_username(self):
        """
        If an existing username is passed in, return that user's profile.
        """
        user = UserProfileFactory.create().user
        self.view.kwargs['username'] = user.profile.username

        eq_(self.view.get_object(), user.profile)
开发者ID:Anmol2307,项目名称:oneanddone,代码行数:8,代码来源:test_views.py

示例5: test_success_url_no_privacy_policy

 def test_success_url_no_privacy_policy(self):
     """
     If the user has not accepted the privacy policy,
     return the url to edit user profile.
     """
     profile = UserProfileFactory.create(privacy_policy_accepted=False)
     self.view.user = profile.user
     eq_(self.view.success_url, reverse_lazy('users.profile.update'))
开发者ID:VarnaSuresh,项目名称:oneanddone,代码行数:8,代码来源:test_views.py

示例6: test_profile_email_without_consent

 def test_profile_email_without_consent(self):
     """
     The email attribute should return 'Email consent denied'
     if they have denied consent.
     """
     profile = UserProfileFactory.create(
         consent_to_email=False,
         user__email='[email protected]')
     eq_(profile.email, 'Email consent denied')
开发者ID:VarnaSuresh,项目名称:oneanddone,代码行数:9,代码来源:test_models.py

示例7: test_profile_email_with_consent

 def test_profile_email_with_consent(self):
     """
     The email attribute should return the user's email
     if they have granted consent.
     """
     profile = UserProfileFactory.create(
         consent_to_email=True,
         user__email='[email protected]')
     eq_(profile.email, '[email protected]')
开发者ID:VarnaSuresh,项目名称:oneanddone,代码行数:9,代码来源:test_models.py

示例8: test_get_object_non_existent_username

    def test_get_object_non_existent_username(self):
        """
        If a non-existent username is passed in, throw a 404.
        """
        user = UserProfileFactory.create().user
        self.view.kwargs['username'] = user.profile.username + str(datetime.today())

        with self.assertRaises(Http404):
            self.view.get_object()
开发者ID:Anmol2307,项目名称:oneanddone,代码行数:9,代码来源:test_views.py

示例9: test_has_profile_and_accepts_privacy_policy

    def test_has_profile_and_accepts_privacy_policy(self):
        """
        If the user has created a profile, and has accepted privacy policy
        call the parent class's dispatch method.
        """
        request = Mock()
        request.user = UserProfileFactory.create(privacy_policy_accepted=True).user

        eq_(self.view.dispatch(request), 'fakemixin')
开发者ID:bitgeeky,项目名称:oneanddone,代码行数:9,代码来源:test_mixins.py

示例10: test_has_profile

    def test_has_profile(self):
        """
        If the user has created a profile, call the parent class's
        dispatch method.
        """
        request = Mock()
        request.user = UserProfileFactory.create().user

        eq_(self.view.dispatch(request), 'fakemixin')
开发者ID:kyoshino,项目名称:oneanddone,代码行数:9,代码来源:test_mixins.py

示例11: test_display_email_with_consent

 def test_display_email_with_consent(self):
     """
     The display_email attribute should return the user's email
     if they have granted consent.
     """
     user = UserProfileFactory.create(
         consent_to_email=True,
         user__email='[email protected]').user
     eq_(user.display_email, '[email protected]')
开发者ID:VarnaSuresh,项目名称:oneanddone,代码行数:9,代码来源:test_models.py

示例12: test_display_email_without_consent

 def test_display_email_without_consent(self):
     """
     The display_email attribute should return 'Email consent denied'
     if they have denied consent.
     """
     user = UserProfileFactory.create(
         consent_to_email=False,
         user__email='[email protected]').user
     eq_(user.display_email, 'Email consent denied')
开发者ID:VarnaSuresh,项目名称:oneanddone,代码行数:9,代码来源:test_models.py

示例13: test_dispatch_existing_profile

    def test_dispatch_existing_profile(self):
        """
        If the user already has a profile, redirect them to the home page.
        """
        request = Mock()
        request.user = UserProfileFactory.create().user

        with patch('oneanddone.users.views.redirect') as redirect:
            eq_(self.view.dispatch(request), redirect.return_value)
            redirect.assert_called_with('base.home')
开发者ID:Anmol2307,项目名称:oneanddone,代码行数:10,代码来源:test_views.py

示例14: test_has_profile_and_not_accepted_privacy_policy

    def test_has_profile_and_not_accepted_privacy_policy(self):
        """
        If the user has created a profile, and has not accepted privacy policy
        redirect them to profile update view.
        """
        request = Mock()
        request.user = UserProfileFactory.create(privacy_policy_accepted=False).user

        with patch('oneanddone.users.mixins.redirect') as redirect:
            eq_(self.view.dispatch(request), redirect.return_value)
            redirect.assert_called_with('users.profile.update')
开发者ID:bitgeeky,项目名称:oneanddone,代码行数:11,代码来源:test_mixins.py

示例15: test_success_url_user_ok

 def test_success_url_user_ok(self):
     """
     If the user has a profile and has accepted the privacy policy,
     return the parent success_url.
     """
     profile = UserProfileFactory.create(privacy_policy_accepted=True)
     self.view.user = profile.user
     success_url_patch = patch('django_browserid.views.Verify.success_url',
                               new_callable=PropertyMock)
     with success_url_patch as parent_success_url:
         parent_success_url.return_value = str(uuid4())
         eq_(self.view.success_url, parent_success_url.return_value)
         parent_success_url.assert_called_once_with()
开发者ID:VarnaSuresh,项目名称:oneanddone,代码行数:13,代码来源:test_views.py


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