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


Python ad_rep_factory.AD_REP_FACTORY类代码示例

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


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

示例1: test_allocation_formula

 def test_allocation_formula(self):
     """ Assert the consumer bonus pool is allocated by proximity and
     consumer counts.
     """
     ad_reps = AD_REP_FACTORY.create_ad_reps(create_count=6)
     # One of these will not be selected for allocation; selects 4 of 5.
     for counter in range(0, 5):
         ad_reps[counter].consumer_points = 100 + counter
         ad_reps[counter].save()
         AD_REP_FACTORY.qualify_ad_rep(ad_reps[counter])
     # This ad_rep is not close.
     ad_reps[5].site_id = 131
     ad_reps[5].consumer_zip_postal = '00927'
     ad_reps[5].consumer_points = 1000
     ad_reps[5].save()
     AD_REP_FACTORY.qualify_ad_rep(ad_reps[5])
     # Allocations are no longer created when the AdRepOrder is created.
     order = ORDER_FACTORY.create_order()
     ad_rep_order = AdRepOrder.objects.create(ad_rep=ad_reps[0], order=order)
     ALLOCATE_BONUS_POOL.run(ad_rep_order.id)
     bonus_pool_allocations = BonusPoolAllocation.objects.filter(
         ad_rep_order=ad_rep_order)
     self.assertEqual(len(bonus_pool_allocations), 5)
     self.assertEqual(
         bonus_pool_allocations.aggregate(Sum('amount'))['amount__sum'],
         Decimal(str(round(order.total * BONUS_POOL_PERCENT / 100, 2))))
开发者ID:wcirillo,项目名称:ten,代码行数:26,代码来源:test_tasks.py

示例2: test_valid_ad_rep

 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')
开发者ID:wcirillo,项目名称:ten,代码行数:35,代码来源:test_ad_rep_account_views.py

示例3: get_ad_rep_default_site

 def get_ad_rep_default_site(self):
     """ Assert the latest ad_rep of site is selected but not a CUSTOMER. """
     ad_rep = AD_REP_FACTORY.create_ad_rep()
     ad_rep.rank = 'CUSTOMER'
     ad_rep.save()
     with self.assertRaises(AdRep.DoesNotExist):
         AdRep.objects.get_ad_rep_for_lead(ad_rep.site)
     ad_rep = AD_REP_FACTORY.create_ad_rep()
     self.assertEqual(ad_rep, AdRep.objects.get_ad_rep_for_lead(ad_rep.site))
开发者ID:wcirillo,项目名称:ten,代码行数:9,代码来源:test_models.py

示例4: test_change_ad_rep

 def test_change_ad_rep(self):
     """ Assert the ad_rep of an ad_rep_order cannot be changed. """
     ad_rep = AD_REP_FACTORY.create_ad_rep()
     order = ORDER_FACTORY.create_order()
     ad_rep_order = AdRepOrder.objects.create(ad_rep=ad_rep, order=order)
     ad_rep_2 = AD_REP_FACTORY.create_ad_rep()
     ad_rep_order.ad_rep = ad_rep_2
     with self.assertRaises(ValidationError):
         ad_rep_order.save()
开发者ID:wcirillo,项目名称:ten,代码行数:9,代码来源:test_models.py

示例5: test_ad_rep_summary_good

 def test_ad_rep_summary_good(self):
     """ Assert ad rep summary loads data for this ad rep. """
     ad_rep = AD_REP_FACTORY.create_ad_rep()
     self.login(email=ad_rep.email, is_ad_rep=True)
     self.assemble_session(self.session)
     ad_rep_recruit = AD_REP_FACTORY.create_ad_rep()
     response = self.client.get(
         "%s%s/" % (reverse('ad-rep-summary'),ad_rep_recruit.id))
     self.assertContains(response, ad_rep_recruit.first_name)
     self.assertContains(response, ad_rep_recruit.email)
开发者ID:wcirillo,项目名称:ten,代码行数:10,代码来源:test_views.py

示例6: test_email_sent

 def test_email_sent(self):
     """ Assert an email is delivered to two ad reps. """
     AD_REP_FACTORY.create_ad_reps(create_count=2)
     mail_prior = len(mail.outbox)
     Email.objects.create(
         subject='send now',
         message='this',
         send_status=1,
         user_type=ContentType.objects.get(model='adrep')
         )
     self.assertEqual(len(mail.outbox), mail_prior + 2)
开发者ID:wcirillo,项目名称:ten,代码行数:11,代码来源:test_email_model.py

示例7: test_more_than_min

 def test_more_than_min(self):
     """ Assert more than the minimum ad_reps can receive an allocation. """
     ad_reps = AD_REP_FACTORY.create_ad_reps(
         create_count=BONUS_POOL_MIN_SHARERS + 1)
     for ad_rep in ad_reps:
         ad_rep.consumer_points = 1
         ad_rep.save()
         AD_REP_FACTORY.qualify_ad_rep(ad_rep)
     order = ORDER_FACTORY.create_order()
     ad_rep_order = AdRepOrder.objects.create(ad_rep=ad_reps[0], order=order)
     ALLOCATE_BONUS_POOL.run(ad_rep_order.id)
     bonus_pool_allocations = BonusPoolAllocation.objects.filter(
         ad_rep_order=ad_rep_order)
     self.assertEqual(len(bonus_pool_allocations), len(ad_reps))
开发者ID:wcirillo,项目名称:ten,代码行数:14,代码来源:test_tasks.py

示例8: test_customer_ad_rep_url

 def test_customer_ad_rep_url(self):
     """ Assert a valid ad_rep_url serves a page with a 200 response,
     including data for an ad rep, abiding by rules omitting contact info for
     ad reps of rank CUSTOMER.
     """
     connector = MockConnector()
     factory = RequestFactory()
     ad_rep = AD_REP_FACTORY.create_ad_rep(url='joeshmoe')
     ad_rep.rank = 'CUSTOMER'
     ad_rep.save()
     request = factory.get('/hudson-valley/joeshmoe/')
     # WSGIRequest does not have a session.
     request.session = self.client.session
     request.session['ad_rep_id'] = ad_rep.id
     request.META['site_id'] = 2
     response = ad_rep_home(request, 'joeshmoe', connector)
     LOG.debug(response.content)
     self.assertEqual(response.status_code, 200)
     self.assertContains(response, 'Advertising Rep')
     self.assertContains(response, '%s %s' % (ad_rep.first_name,
         ad_rep.last_name))
     self.assertContains(response, ad_rep.company)
     self.assertNotContains(response,
         format_phone(ad_rep.primary_phone_number))
     self.assertNotContains(response,
         format_phone(ad_rep.home_phone_number))
     self.assertNotContains(response, 'Advertising Representative</em')
     self.assertContains(response, ad_rep.email)
     self.assertContains(response, 'frm_consumer_registration')
     self.assertContains(response, 'frm_subscriber_registration')
     self.assertContains(response, 'input name="email"')
     self.assertContains(response, 'input name="consumer_zip_postal"')
     self.assertContains(response, 'input name="mobile_phone_number"')
     self.assertContains(response, 'input name="subscriber_zip_postal"')
     self.assertContains(response, 'name="carrier"')
开发者ID:wcirillo,项目名称:ten,代码行数:35,代码来源:test_views.py

示例9: test_ad_rep_signature

 def test_ad_rep_signature(self):
     """ Assert the referring ad rep of a lead is included in the signature.
     """
     ad_rep_lead = AD_REP_LEAD_FACTORY.create_ad_rep_lead()
     ad_rep_lead.ad_rep = AD_REP_FACTORY.create_ad_rep()
     ad_rep_lead.save()
     mail_prior = len(mail.outbox)
     AD_REP_INVITE_TASK.run(test_mode=[ad_rep_lead])
     LOG.debug(mail.outbox[mail_prior].alternatives[0][0])
     LOG.debug(mail.outbox[mail_prior].body)
     self.assertEqual(len(mail.outbox), mail_prior + 1)
     self.assertTrue(ad_rep_lead.ad_rep.first_name in
         mail.outbox[mail_prior].alternatives[0][0])
     self.assertTrue(ad_rep_lead.ad_rep.last_name in
         mail.outbox[mail_prior].alternatives[0][0])
     self.assertTrue(ad_rep_lead.ad_rep.email in
         mail.outbox[mail_prior].alternatives[0][0])
     self.assertTrue(ad_rep_lead.ad_rep.url in
         mail.outbox[mail_prior].alternatives[0][0])
     self.assertTrue(ad_rep_lead.ad_rep.first_name in
         mail.outbox[mail_prior].body)
     self.assertTrue(ad_rep_lead.ad_rep.last_name in
         mail.outbox[mail_prior].body)
     self.assertTrue(ad_rep_lead.ad_rep.email in
         mail.outbox[mail_prior].body)
     self.assertTrue(ad_rep_lead.ad_rep.url in mail.outbox[mail_prior].body)
开发者ID:wcirillo,项目名称:ten,代码行数:26,代码来源:test_ad_rep_invite.py

示例10: test_normal_ad_rep_url

 def test_normal_ad_rep_url(self):
     """ Assert a valid ad_rep_url serves a page with a 200 response,
     including data for a non-CUSTOMER ranked ad rep, will include contact
     phone number and title.
     """
     connector = MockConnector()
     factory = RequestFactory()
     ad_rep = AD_REP_FACTORY.create_ad_rep(url='jenkins_test1001')
     AdRepWebGreeting.objects.create(ad_rep=ad_rep, web_greeting='xxx999')
     request = factory.get('/hudson-valley/jenkins_test1001/')
     # WSGIRequest does not have a session.
     request.session = self.client.session
     request.session['ad_rep_id'] = ad_rep.id
     request.META['site_id'] = 2
     response = ad_rep_home(request, 'jenkins_test1001', connector)
     self.assertEqual(response.status_code, 200)
     self.assertContains(response, 'Advertising Representative</em')
     self.assertContains(response, '%s %s' % (ad_rep.first_name,
         ad_rep.last_name))
     self.assertContains(response, ad_rep.company)
     self.assertContains(response,
         format_phone(ad_rep.primary_phone_number))
     self.assertContains(response, format_phone(ad_rep.home_phone_number))
     self.assertContains(response, ad_rep.email)
     self.assertContains(response, ad_rep.ad_rep_web_greeting.web_greeting)
开发者ID:wcirillo,项目名称:ten,代码行数:25,代码来源:test_views.py

示例11: test_lead_for_ad_rep

 def test_lead_for_ad_rep(self):
     """ Assert the email is 'from' an ad_rep and the ad_rep gets a copy.
     """
     # This first ad_rep on the site will get this lead.
     ad_rep = AD_REP_FACTORY.create_ad_reps(create_count=2)[0]
     mail_prior = len(mail.outbox)
     offer = OFFER_FACTORY.create_offer()
     advertiser = offer.business.advertiser
     self.prep_advertiser(advertiser, 1)
     WarmLeadEmailTask().run()
     self.assertEqual(mail.outbox[mail_prior].subject,
         'Publish your first coupon today')
     self.assertFalse('/hudson-valley/create-coupon/' in
         mail.outbox[mail_prior].body)
     self.assertFalse('/hudson-valley/create-coupon/' in
         mail.outbox[mail_prior].alternatives[0][0])
     target_string = '/hudson-valley/join-me/%s/create-coupon/' % ad_rep.url
     self.assertTrue(target_string in mail.outbox[mail_prior].body)
     self.assertTrue(target_string in
         mail.outbox[mail_prior].alternatives[0][0])
     # Assert dynamic text that swings on schedule_item.
     self.assertTrue("This coupon could be complete with just a few clicks."
         in mail.outbox[mail_prior].alternatives[0][0])
     self.assertEqual(mail.outbox[mail_prior + 1].to, [ad_rep.email])
     self.assertEqual(mail.outbox[mail_prior + 1].subject,
         'WARM LEAD: Publish your first coupon today')
开发者ID:wcirillo,项目名称:ten,代码行数:26,代码来源:test_warm_leads_email_task.py

示例12: test_send_offer_130_ad_rep

 def test_send_offer_130_ad_rep(self):
     """ Assert task for 130 day old advertiser acct with a referring ad_rep
     generates an email with a promotion code.
     """
     promo_code = 'ONEYEAR399'
     coupon = COUPON_FACTORY.create_coupon()
     advertiser = coupon.offer.business.advertiser
     ad_rep = AD_REP_FACTORY.create_ad_rep()
     AdRepAdvertiser.objects.create(ad_rep=ad_rep, advertiser=advertiser)
     mail_prior = len(mail.outbox)
     self.prep_advertiser(advertiser, 130)
     WarmLeadEmailTask().run()
     self.assertEqual(mail.outbox[mail_prior].subject,
         'Publish up to 10 coupons and save $100')
     self.assertEqual(mail.outbox[mail_prior + 1].subject,
         'WARM LEAD: Publish up to 10 coupons and save $100')
     self.assertTrue('An email was sent on your behalf.' in
         mail.outbox[mail_prior + 1].body)
     # Assert text version contains Sales Rep signature.
     self.assertTrue('Reputable Salesperon'
         in mail.outbox[mail_prior + 1].body)
     # Assert text version promo_code.
     self.assertTrue(promo_code in mail.outbox[mail_prior + 1].body)
     # Assert HTML version contains promo_code.
     self.assertTrue(promo_code in
         mail.outbox[mail_prior + 1].alternatives[0][0])
     # Assert dynamic text that swings on schedule_item.
     self.assertTrue('a hundred bucks</a>' in
         mail.outbox[mail_prior].alternatives[0][0])
开发者ID:wcirillo,项目名称:ten,代码行数:29,代码来源:test_warm_leads_email_task.py

示例13: setUp

 def setUp(self):
     """ Create test users: ad rep and ad rep lead. """
     self.email_task = AdRepMtgReminderEmail()
     self.create_ad_rep_lead(32)
     self.ad_rep_lead = self.create_ad_rep_lead(2)
     self.ad_rep = AD_REP_FACTORY.create_ad_rep()
     self.ad_rep.email_subscription.add(self.email_task.list_id)
开发者ID:wcirillo,项目名称:ten,代码行数:7,代码来源:test_ad_rep_reminder_email_task.py

示例14: test_ad_rep_summary_404

 def test_ad_rep_summary_404(self):
     """ Assert ad rep summary returns 404 when no ad_rep_id. """
     ad_rep = AD_REP_FACTORY.create_ad_rep()
     self.login(email=ad_rep.email, is_ad_rep=True)
     self.assemble_session(self.session)
     response = self.client.get(reverse('ad-rep-summary'))
     self.assertEqual(response.status_code, 404)
开发者ID:wcirillo,项目名称:ten,代码行数:7,代码来源:test_views.py

示例15: test_downline_recruits

 def test_downline_recruits(self):
     """ Assert recruits and their referred customer counts display. """
     ad_rep_list = AD_REP_FACTORY.create_ad_reps(create_count=3)
     parent_ad_rep = ad_rep_list[0]
     child_ad_rep_1 = ad_rep_list[1]
     child_ad_rep_2 = ad_rep_list[2]
     child_ad_rep_1.parent_ad_rep = parent_ad_rep
     child_ad_rep_1.save()
     child_ad_rep_2.parent_ad_rep = parent_ad_rep
     child_ad_rep_2.save()
     consumer = CONSUMER_FACTORY.create_consumer()
     AdRepConsumer.objects.create(ad_rep=child_ad_rep_1, consumer=consumer)
     self.session['ad_rep_id'] = parent_ad_rep.id
     self.login(email=parent_ad_rep.email)
     self.assemble_session(self.session)
     response = self.client.get(reverse('ad-rep-downline-recruits'))
     self.assertEqual(response.request['PATH_INFO'], 
         '/hudson-valley/ad-rep/downline-recruits/')
     self.assertContains(response, 
         'Click a name to display contact information')
     self.assertContains(response, '%s %s' % (child_ad_rep_1.first_name, 
         child_ad_rep_1.last_name))
     self.assertContains(response, '%s %s' % (child_ad_rep_2.first_name, 
         child_ad_rep_2.last_name))
     self.assertContains(response, '<strong>1</strong>')
开发者ID:wcirillo,项目名称:ten,代码行数:25,代码来源:test_ad_rep_account_views.py


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