本文整理匯總了Python中consumer.factories.consumer_factory.CONSUMER_FACTORY.create_consumers方法的典型用法代碼示例。如果您正苦於以下問題:Python CONSUMER_FACTORY.create_consumers方法的具體用法?Python CONSUMER_FACTORY.create_consumers怎麽用?Python CONSUMER_FACTORY.create_consumers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類consumer.factories.consumer_factory.CONSUMER_FACTORY
的用法示例。
在下文中一共展示了CONSUMER_FACTORY.create_consumers方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_valid_ad_rep
# 需要導入模塊: from consumer.factories.consumer_factory import CONSUMER_FACTORY [as 別名]
# 或者: from consumer.factories.consumer_factory.CONSUMER_FACTORY import create_consumers [as 別名]
def test_valid_ad_rep(self):
""" Assert view displays downline consumer and qualified consumer counts
for each.
"""
child_ad_rep1, parent_ad_rep = AD_REP_FACTORY.create_generations(
create_count=2)
child_ad_rep2 = AD_REP_FACTORY.create_ad_rep()
child_ad_rep2.parent_ad_rep = parent_ad_rep
child_ad_rep2.save()
consumers = CONSUMER_FACTORY.create_consumers(create_count=3)
for consumer in consumers:
CONSUMER_FACTORY.qualify_consumer(consumer)
AdRepConsumer.objects.create(consumer=consumers[0],
ad_rep=child_ad_rep1)
AdRepConsumer.objects.create(consumer=consumers[1],
ad_rep=child_ad_rep2)
AdRepConsumer.objects.create(consumer=consumers[2],
ad_rep=child_ad_rep2)
self.client.login(username='super', password='secret')
response = self.client.get(reverse('admin-downline-consumers',
kwargs={'ad_rep_id': parent_ad_rep.id}))
self.assertEqual(response.status_code, 200)
self.assertContains(response, 'Recruitment Activity for %s %s' %
(parent_ad_rep.first_name, parent_ad_rep.last_name))
self.assertContains(response, 'Customers')
self.assertContains(response, '%s %s' %
(child_ad_rep1.first_name, child_ad_rep1.last_name))
self.assertContains(response,
"Click a name to view that Advertising Representative's")
self.assertTrue(response.content.count('>1</strong>'), 2)
# Output is sorted by consumer count;, child_ad_rep2 comes first.
self.assertTrue(response.content.index(child_ad_rep2.first_name) <
response.content.index(child_ad_rep1.first_name))
# Only market managers (rank) get this text:
self.assertNotContains(response, 'commission is paid to you')
示例2: test_redo_update
# 需要導入模塊: from consumer.factories.consumer_factory import CONSUMER_FACTORY [as 別名]
# 或者: from consumer.factories.consumer_factory.CONSUMER_FACTORY import create_consumers [as 別名]
def test_redo_update(self):
""" Assert a flyer that has already been calculated into the consumer
bonus pool is not calculated again.
"""
ad_rep = AD_REP_FACTORY.create_ad_rep()
self.assertEqual(ad_rep.consumer_points, 0)
flyer = Flyer.objects.create(site_id=2, is_approved=True)
flyer_recipients = CONSUMER_FACTORY.create_consumers(create_count=5)
for consumer in flyer_recipients:
AdRepConsumer.objects.create(ad_rep=ad_rep, consumer_id=consumer.id)
BonusPoolFlyer.objects.create(flyer_id=flyer.id, calculate_status='2')
UPDATE_CONSUMER_BONUS_POOL(flyer.id, [])
ad_rep = AdRep.objects.get(id=ad_rep.id)
self.assertEqual(ad_rep.consumer_points, 0)
示例3: qualify_ad_rep
# 需要導入模塊: from consumer.factories.consumer_factory import CONSUMER_FACTORY [as 別名]
# 或者: from consumer.factories.consumer_factory.CONSUMER_FACTORY import create_consumers [as 別名]
def qualify_ad_rep(ad_rep):
""" Set the condition such that ad_rep.is_qualified() returns True. """
consumers = CONSUMER_FACTORY.create_consumers(create_count=10)
for consumer in consumers:
CONSUMER_FACTORY.qualify_consumer(consumer)
AdRepConsumer.objects.create(ad_rep=ad_rep, consumer=consumer)