當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。