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


Python CONSUMER_FACTORY.qualify_consumer方法代碼示例

本文整理匯總了Python中consumer.factories.consumer_factory.CONSUMER_FACTORY.qualify_consumer方法的典型用法代碼示例。如果您正苦於以下問題:Python CONSUMER_FACTORY.qualify_consumer方法的具體用法?Python CONSUMER_FACTORY.qualify_consumer怎麽用?Python CONSUMER_FACTORY.qualify_consumer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在consumer.factories.consumer_factory.CONSUMER_FACTORY的用法示例。


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

示例1: test_send_flyers_this_week

# 需要導入模塊: from consumer.factories.consumer_factory import CONSUMER_FACTORY [as 別名]
# 或者: from consumer.factories.consumer_factory.CONSUMER_FACTORY import qualify_consumer [as 別名]
 def test_send_flyers_this_week(self):
     """  Assert a flyer is sent. Assert the coupon links are correct. """
     flyer = Flyer.objects.create(site_id=2, is_approved=2)
     slots = SLOT_FACTORY.create_slots(create_count=2)
     coupons = SLOT_FACTORY.prepare_slot_coupons_for_flyer(slots)
     for coupon  in coupons:
         append_coupon_to_flyer(flyer, coupon)
     # It needs an eligible recipient.
     consumer = CONSUMER_FACTORY.create_consumer()
     CONSUMER_FACTORY.qualify_consumer(consumer)
     send_flyers_this_week()
     self.assertEqual(len(mail.outbox), 2)
     self.assertEqual(mail.outbox[0].subject, 'Recent Hudson Valley coupons')
     # Find the specific email to our test consumer.
     x = 0
     while x < len(mail.outbox):
         if mail.outbox[x].to[0] == consumer.email:
             break
         x += 1
     self.assertEqual(mail.outbox[0].extra_headers['From'], 
         '10HudsonValleyCoupons.com <[email protected]>')
     target_path = '%s%s' % (settings.HTTP_PROTOCOL_HOST,
         reverse('opt_out', kwargs={'payload':
             PAYLOAD_SIGNING.create_payload(email=consumer.email)}))
     # We cannot predict the signed email payload, so trim that piece of the
     # url.
     payload = target_path.split('/')[-2]
     target_path = '/'.join(target_path.split('/')[:-2]) + '/'
     self.assertTrue(target_path in
         mail.outbox[x].extra_headers['List-Unsubscribe'])
     LOG.debug(mail.outbox[0].body)
     # Assert the opt out link is in the html version of the email.
     self.assertTrue(target_path in mail.outbox[0].alternatives[0][0])
     self.assertTrue('<mailto:list_unsubscribe-consumer_standard_flyer-' in 
         mail.outbox[0].extra_headers['List-Unsubscribe'])
     self.assertTrue('@bounces.10coupons.com>' in 
         mail.outbox[0].extra_headers['List-Unsubscribe'])
     for coupon in coupons:
         # We cannot predict the random obfuscation of the email hash.
         # So pass it as blank.
         target_path = '%s%s' % (settings.HTTP_PROTOCOL_HOST,
             reverse('flyer-click', args=[coupon.id, payload]))
         target_path = '/'.join(target_path.split('/')[:-2]) + '/'
         # Assert this url is in plain text version.
         self.assertTrue(target_path in mail.outbox[0].body)
         # Assert this url is in html version.
         self.assertTrue(target_path in mail.outbox[0].alternatives[0][0])
     # Assert a signed payload exists in each version.
     # The payload for the opt-out link does not need to be the same string
     # as the payload for the header, as long as they both load to the same.
     payload = mail.outbox[x].body[
         mail.outbox[x].body.index('opt-out-list/') + 13:].split('/')[0]
     self.assertEqual(PAYLOAD_SIGNING.parse_payload(payload)['email'],
         consumer.email)
     self.assertTrue(payload in mail.outbox[x].alternatives[0][0])
     flyer = Flyer.objects.get(id=flyer.id)
     # Assert the flyer is now marked as sent.
     self.assertTrue(flyer.send_status, '2')
     self.assertTrue(FlyerConsumer.objects.filter(flyer=flyer, 
         consumer__id=consumer.id).count(), 1)
開發者ID:wcirillo,項目名稱:ten,代碼行數:62,代碼來源:test_flyer.py

示例2: test_valid_ad_rep

# 需要導入模塊: from consumer.factories.consumer_factory import CONSUMER_FACTORY [as 別名]
# 或者: from consumer.factories.consumer_factory.CONSUMER_FACTORY import qualify_consumer [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')
開發者ID:wcirillo,項目名稱:ten,代碼行數:37,代碼來源:test_ad_rep_account_views.py

示例3: test_delete_subscriber

# 需要導入模塊: from consumer.factories.consumer_factory import CONSUMER_FACTORY [as 別名]
# 或者: from consumer.factories.consumer_factory.CONSUMER_FACTORY import qualify_consumer [as 別名]
 def test_delete_subscriber(self):
     """ Delete a subscriber that has a consumer and assert the consumer is 
     not dropped.
     """
     consumer = CONSUMER_FACTORY.create_consumer()
     CONSUMER_FACTORY.qualify_consumer(consumer)
     mobile_phone = consumer.subscriber.mobile_phones.all()[0]
     consumer.subscriber.delete()
     with self.assertRaises(MobilePhone.DoesNotExist):
         MobilePhone.objects.get(id=mobile_phone.id)
     try:
         consumer = Consumer.objects.get(id=consumer.id)
     except Consumer.DoesNotExist:
         self.fail('Retain Consumer when subscriber is deleted!')
     self.assertEqual(consumer.subscriber, None)
開發者ID:wcirillo,項目名稱:ten,代碼行數:17,代碼來源:test_models.py

示例4: test_get_subscriber_in_session

# 需要導入模塊: from consumer.factories.consumer_factory import CONSUMER_FACTORY [as 別名]
# 或者: from consumer.factories.consumer_factory.CONSUMER_FACTORY import qualify_consumer [as 別名]
 def test_get_subscriber_in_session(self):
     """ Assert GET with subscriber in session pre-fills the form. """
     consumer = CONSUMER_FACTORY.create_consumer()
     CONSUMER_FACTORY.qualify_consumer(consumer)
     create_consumer_in_session(self, consumer)
     self.assemble_session(self.session)
     LOG.debug("session = %s" % self.session)
     slot = SLOT_FACTORY.create_slot()
     coupon = slot.slot_time_frames.latest('id').coupon
     response = self.client.get(reverse('show-send-sms-single-coupon',
         kwargs = {'coupon_id':coupon.id}))
     LOG.debug("response: %s" % response.content)
     self.assertContains(response, 'value="%s"' %
         consumer.subscriber.mobile_phones.latest('id').mobile_phone_number)
     self.assertContains(response,
         '<option value="2" selected="selected">AT&amp;T</option>')
開發者ID:wcirillo,項目名稱:ten,代碼行數:18,代碼來源:test_views.py

示例5: test_con_sub_reg_confirmation

# 需要導入模塊: from consumer.factories.consumer_factory import CONSUMER_FACTORY [as 別名]
# 或者: from consumer.factories.consumer_factory.CONSUMER_FACTORY import qualify_consumer [as 別名]
 def test_con_sub_reg_confirmation(self):
     """ Assert consumer + subscriber registration success confirmation page
     displays correctly if is_email_verified is not set in session.
     """
     consumer = CONSUMER_FACTORY.create_consumer()
     CONSUMER_FACTORY.qualify_consumer(consumer)
     create_consumer_in_session(self, consumer)
     # Remove is_email_verified from session.
     del self.session['consumer']['is_email_verified']
     self.assemble_session(self.session)
     response = self.client.post(reverse('con-sub-reg-confirmation'))
     self.assertTemplateUsed(response,
         'registration/display_con_sub_reg_confirmation.html')
     self.assertTemplateUsed(response,
         'include/dsp/dsp_subscriber_registration_confirmation.html')
     self.assertTemplateUsed(response,
         'include/dsp/dsp_con_sub_reg_confirmation.html')
開發者ID:wcirillo,項目名稱:ten,代碼行數:19,代碼來源:test_views.py

示例6: test_home_with_subscriber

# 需要導入模塊: from consumer.factories.consumer_factory import CONSUMER_FACTORY [as 別名]
# 或者: from consumer.factories.consumer_factory.CONSUMER_FACTORY import qualify_consumer [as 別名]
 def test_home_with_subscriber(self):
     """ Assert xfbml for facebook like appears for subscriber on home page.
     """
     consumer = CONSUMER_FACTORY.create_consumer()
     CONSUMER_FACTORY.qualify_consumer(consumer)
     mobile_phone = consumer.subscriber.mobile_phones.all()[0]
     mobile_phone.is_verified = False
     mobile_phone.save()
     create_consumer_in_session(self, consumer)
     self.assemble_session(self.session)
     response = self.client.get(reverse('all-coupons'))
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.request['PATH_INFO'], 
         '/hudson-valley/coupons/')
     self.assertTemplateUsed(response, 'coupon/display_all_coupons.html')
     self.assertTemplateUsed(response, 'include/dsp/dsp_share_site.html')
     # Assumes contest is running:
     self.assertContains(response, 'load_like_contest_not_qualified')
開發者ID:wcirillo,項目名稱:ten,代碼行數:20,代碼來源:test_view_coupon.py

示例7: qualify_ad_rep

# 需要導入模塊: from consumer.factories.consumer_factory import CONSUMER_FACTORY [as 別名]
# 或者: from consumer.factories.consumer_factory.CONSUMER_FACTORY import qualify_consumer [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)
開發者ID:wcirillo,項目名稱:ten,代碼行數:8,代碼來源:ad_rep_factory.py

示例8: prep_test

# 需要導入模塊: from consumer.factories.consumer_factory import CONSUMER_FACTORY [as 別名]
# 或者: from consumer.factories.consumer_factory.CONSUMER_FACTORY import qualify_consumer [as 別名]
 def prep_test(self, only_subscriber=False):
     """ Get consumer and subscriber for tests. """
     self.subscriber = Subscriber.objects.get(id=6)
     if not only_subscriber:
         self.consumer = CONSUMER_FACTORY.create_consumer()
         CONSUMER_FACTORY.qualify_consumer(self.consumer)
開發者ID:wcirillo,項目名稱:ten,代碼行數:8,代碼來源:test_contest.py


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