本文整理汇总了Python中affiliates.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()))
示例2: 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()))
示例3: 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()))
示例4: 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)
示例5: 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')
示例6: 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)
示例7: 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')
示例8: 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, '[email protected]'),
False)
示例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')
示例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)
示例11: 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)
示例12: 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)
示例13: 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))
示例14: test_country_missing
def test_country_missing(self, login, update_user_info):
"""
If the user's country is not included in the signed_request, keep their
old country value intact.
"""
user = FacebookUserFactory.create(country='us')
payload = create_payload(user_id=user.id)
del payload['user']['country']
self.load_app(payload)
eq_(login.called, True)
eq_(login.call_args[0][1].country, 'us')
示例15: test_country_saved
def test_country_saved(self, login, update_user_info):
"""
When a user enters the app, their country should be set and
login should be called with the updated user object so that it will be
saved to the database.
"""
user = FacebookUserFactory.create(country='us')
payload = create_payload(user_id=user.id, country='fr')
self.load_app(payload)
eq_(login.called, True)
eq_(login.call_args[0][1].country, 'fr')