當前位置: 首頁>>代碼示例>>Python>>正文


Python tests.FacebookUserFactory類代碼示例

本文整理匯總了Python中facebook.tests.FacebookUserFactory的典型用法代碼示例。如果您正苦於以下問題:Python FacebookUserFactory類的具體用法?Python FacebookUserFactory怎麽用?Python FacebookUserFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了FacebookUserFactory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_filter_country

    def test_filter_country(self):
        """
        If the country field is set, only return users within that country.
        """
        user1 = FacebookUserFactory.create(leaderboard_position=1, country='us')
        FacebookUserFactory.create(leaderboard_position=2, country='fr')
        user3 = FacebookUserFactory.create(leaderboard_position=3, country='us')

        form = LeaderboardFilterForm({'country': 'us'})
        eq_([user1, user3], list(form.get_top_users()))
開發者ID:Hugochazz,項目名稱:affiliates,代碼行數:10,代碼來源:test_forms.py

示例2: test_get_top_users

    def test_get_top_users(self):
        """
        Test that get_top_users, er, gets the top users ranked by
        leaderboard_position.
        """
        user1 = FacebookUserFactory.create(leaderboard_position=1)
        user2 = FacebookUserFactory.create(leaderboard_position=2)
        user3 = FacebookUserFactory.create(leaderboard_position=3)

        form = LeaderboardFilterForm()
        eq_([user1, user2, user3], list(form.get_top_users()))
開發者ID:Hugochazz,項目名稱:affiliates,代碼行數:11,代碼來源:test_forms.py

示例3: test_exclude_unranked_users

    def test_exclude_unranked_users(self):
        """
        If a user has a leaderboard position of -1, do not include them in the
        top users list.
        """
        user1 = FacebookUserFactory.create(leaderboard_position=1)
        FacebookUserFactory.create(leaderboard_position=-1)
        user3 = FacebookUserFactory.create(leaderboard_position=2)

        form = LeaderboardFilterForm()
        eq_([user1, user3], list(form.get_top_users()))
開發者ID:Hugochazz,項目名稱:affiliates,代碼行數:11,代碼來源:test_forms.py

示例4: test_total_for_month

 def test_total_for_month(self):
     """Test that the click sum logic is correct."""
     user = FacebookUserFactory.create()
     self._mkstats(user, 2012, 5, 5)
     self._mkstats(user, 2012, 3, 7)
     self._mkstats(user, 2012, 5, 2)
     eq_(self.manager.total_for_month(user, 2012, 5), 7)
開發者ID:Hugochazz,項目名稱:affiliates,代碼行數:7,代碼來源:test_managers.py

示例5: test_purge_email

    def test_purge_email(self):
        """
        If a user is being purged and has banners that have passed ad review,
        send an email to the admin with info about the ads that need to be
        removed.
        """
        user = FacebookUserFactory.create()
        instance1 = FacebookBannerInstanceFactory.create(
            user=user, review_status=FacebookBannerInstance.PASSED)
        instance2 = FacebookBannerInstanceFactory.create(
            user=user, review_status=FacebookBannerInstance.PASSED)
        instance3 = FacebookBannerInstanceFactory.create(
            user=user, review_status=FacebookBannerInstance.FAILED)

        user_id = 'User ID: %s' % user.id
        instance1_id = 'Banner Instance ID: %s' % instance1.id
        instance2_id = 'Banner Instance ID: %s' % instance2.id
        instance3_id = 'Banner Instance ID: %s' % instance3.id
        self.manager.purge_user_data(user)

        eq_(len(mail.outbox), 1)
        msg = mail.outbox[0]
        ok_('[email protected]' in msg.to)
        ok_(user_id in msg.body)
        ok_(instance1_id in msg.body)
        ok_(instance2_id in msg.body)
        ok_(not instance3_id in msg.body)
開發者ID:Hugochazz,項目名稱:affiliates,代碼行數:27,代碼來源:test_managers.py

示例6: test_old_user_banner_list

    def test_old_user_banner_list(self):
        """If the logged in user is not new, render the banner list page."""
        user = FacebookUserFactory.create()
        self.client.fb_login(user)

        response = self.banner_list()
        self.assertTemplateUsed(response, 'facebook/banner_list.html')
開發者ID:disegnovitruviano,項目名稱:affiliates,代碼行數:7,代碼來源:test_views.py

示例7: test_create_link_no_account

 def test_create_link_no_account(self):
     """
     If no user exists with the given email, create_link should return False.
     """
     fb_user = FacebookUserFactory.create()
     eq_(self.manager.create_link(fb_user, 'does.not.exis[email protected]'),
         False)
開發者ID:Hugochazz,項目名稱:affiliates,代碼行數:7,代碼來源:test_managers.py

示例8: test_new_user_first_run

    def test_new_user_first_run(self):
        """If the logged in user is new, redirect them to the first run page."""
        user = FacebookUserFactory.create()
        self.client.fb_login(user)

        response = self.banner_list()
        self.assertTemplateUsed(response, 'facebook/first_run.html')
開發者ID:disegnovitruviano,項目名稱:affiliates,代碼行數:7,代碼來源:test_views.py

示例9: test_save_locale

 def test_save_locale(self):
     """The form should save the current locale on the instance."""
     locale = FacebookBannerLocaleFactory.create(locale='es')
     with self.activate('es'):
         form = self.form('es', {'text': 'asdf', 'banner': locale.banner.id},
                          user=FacebookUserFactory.create())
         instance = form.save()
         eq_(instance.locale, 'es')
開發者ID:Hugochazz,項目名稱:affiliates,代碼行數:8,代碼來源:test_forms.py

示例10: test_valid_user

 def test_valid_user(self, purge_user_data):
     """
     If the supplied user id is valid, call purge_user_data with the user.
     """
     user = FacebookUserFactory.create()
     response = self.deauthorize({'user_id': user.id})
     eq_(response.status_code, 200)
     purge_user_data.assert_called_with(user)
開發者ID:disegnovitruviano,項目名稱:affiliates,代碼行數:8,代碼來源:test_views.py

示例11: test_create_link_affiliates_already_linked

 def test_create_link_affiliates_already_linked(self):
     """
     If the Affiliates user is already linked to another account, create_link
     should return False.
     """
     link = FacebookAccountLinkFactory.create(is_active=True)
     fb_user = FacebookUserFactory.create()
     result = self.manager.create_link(fb_user, link.affiliates_user.email)
     eq_(result, False)
開發者ID:Hugochazz,項目名稱:affiliates,代碼行數:9,代碼來源:test_managers.py

示例12: test_notify_new_instance

 def test_notify_new_instance(self):
     """
     If the instance being saved is new, no notification should be created.
     """
     user = FacebookUserFactory.create()
     banner = FacebookBannerFactory.create()
     instance = FacebookBannerInstanceFactory(user=user, banner=banner)
     instance.save()
     eq_(user.appnotification_set.exists(), False)
開發者ID:disegnovitruviano,項目名稱:affiliates,代碼行數:9,代碼來源:test_models.py

示例13: test_user_found

 def test_user_found(self):
     """
     If there is an authenticated session with an existing user, the
     specified user should be available via the user attribute.
     """
     request = self.request()
     user = FacebookUserFactory.create()
     request.session[SESSION_KEY] = user.id
     self.auth_middleware.process_request(request)
     eq_(request.user, user)
開發者ID:Hugochazz,項目名稱:affiliates,代碼行數:10,代碼來源:test_middleware.py

示例14: test_account_link_form

    def test_account_link_form(self):
        """
        If the user doesn't have a linked account, the account_link_form should
        be included in the context.
        """
        unlinked_account = FacebookUserFactory.create()
        ok_("account_link_form" in self._app_context(user=unlinked_account))

        account_link = FacebookAccountLinkFactory.create(is_active=True)
        linked_account = account_link.facebook_user
        ok_("account_link_form" not in self._app_context(user=linked_account))
開發者ID:hfeeki,項目名稱:affiliates,代碼行數:11,代碼來源:test_context_processors.py

示例15: test_user_non_fb_app

 def test_user_non_fb_app(self):
     """
     If there is an authenticated session with an existing user outside of
     the app, the specified user should not be a FacebookUser.
     """
     request = self.request(url='/')
     user = FacebookUserFactory.create()
     request.session[SESSION_KEY] = user.id
     self.auth_middleware.process_request(request)
     ok_(not request.user == user)
     eq_(request.user.is_anonymous(), True)
開發者ID:Hugochazz,項目名稱:affiliates,代碼行數:11,代碼來源:test_middleware.py


注:本文中的facebook.tests.FacebookUserFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。