本文整理匯總了Python中consumer.factories.consumer_factory.CONSUMER_FACTORY.create_consumer方法的典型用法代碼示例。如果您正苦於以下問題:Python CONSUMER_FACTORY.create_consumer方法的具體用法?Python CONSUMER_FACTORY.create_consumer怎麽用?Python CONSUMER_FACTORY.create_consumer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類consumer.factories.consumer_factory.CONSUMER_FACTORY
的用法示例。
在下文中一共展示了CONSUMER_FACTORY.create_consumer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_view_single_coupon
# 需要導入模塊: from consumer.factories.consumer_factory import CONSUMER_FACTORY [as 別名]
# 或者: from consumer.factories.consumer_factory.CONSUMER_FACTORY import create_consumer [as 別名]
def test_view_single_coupon(self):
""" Assert a valid coupon displays correctly with a consumer in session.
"""
slot = SLOT_FACTORY.create_slot()
coupon = slot.slot_time_frames.latest('id').coupon
coupon.is_valid_thursday = False
coupon.save()
coupon.default_restrictions.add(3)
business = coupon.offer.business
consumer = CONSUMER_FACTORY.create_consumer(subscription_list=False)
create_consumer_in_session(self, consumer)
self.assemble_session(self.session)
self.assertEqual(coupon.consumer_actions.filter(action=2).count(), 0)
response = self.client.get(reverse('view-single-coupon',
kwargs={'slug': coupon.slug(), 'coupon_id': coupon.id}))
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'coupon/display_single_coupon.html')
self.assertTemplateUsed(response, 'include/dsp/dsp_single_coupon.html')
self.assertContains(response, '<meta name="robots" content="noydir">')
self.assertContains(response, '<meta name="robots" content="noodp">')
self.assertContains(response, '<a class="button largeBtn" ' +
'href="/hudson-valley/coupon/%s/" rel="nofollow">' % coupon.id)
self.assertContains(response,
'href="/hudson-valley/"><div >HudsonValley</div>')
self.assertContains(response,
'href="/hudson-valley/coupons/%s/%s/">%s' % (
business.slug(), business.id, business.business_name))
self.assertContains(response, 'class="business_name">%s' %
business.business_name)
self.assertContains(response, 'class="headline">%s' %
coupon.offer.headline)
self.assertContains(response,
'<h4 class="qualifier">\n %s\n' %
coupon.offer.qualifier)
self.assertContains(response, 'Tax and Gratuity Not Included.')
self.assertContains(response,
'No cash value. Not valid in combination with other offers.')
self.assertContains(response, 'Coupon void if altered.')
self.assertContains(response,
'class="valid_days">Offer not valid Thursdays.')
self.assertContains(response,
'class="redemption_window">Valid through %s' %
frmt_expiration_date_for_dsp(coupon.expiration_date))
self.assertNotContains(response, 'Send this coupon to your inbox.')
self.assertNotContains(response, 'Send My Coupon')
# Assumes contest is running:
self.assertContains(response, '%s%s' % ('Create a coupon like',
' this for YOUR business'))
# Check for consumer action recorded for this coupon
self.assertEqual(coupon.consumer_actions.filter(action=2).count(), 1)
# Check for facebook meta for like button.
self.assertTemplateUsed(response, 'include/dsp/dsp_facebook_meta.html')
self.assertContains(response,
'meta property="og:url" content="%s/hudson-valley/coupon-%s/%s/"' %
(settings.HTTP_PROTOCOL_HOST, coupon.slug(), coupon.id))
self.assertTemplateUsed(response,
'include/dsp/dsp_facebook_like_small.html')
self.assertContains(response,
'fb:like href="%s/hudson-valley/coupon-%s/%s/"' %
(settings.HTTP_PROTOCOL_HOST, coupon.slug(), coupon.id))
示例2: test_downline_recruits
# 需要導入模塊: from consumer.factories.consumer_factory import CONSUMER_FACTORY [as 別名]
# 或者: from consumer.factories.consumer_factory.CONSUMER_FACTORY import create_consumer [as 別名]
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>')
示例3: test_create_relate_ad_rep
# 需要導入模塊: from consumer.factories.consumer_factory import CONSUMER_FACTORY [as 別名]
# 或者: from consumer.factories.consumer_factory.CONSUMER_FACTORY import create_consumer [as 別名]
def test_create_relate_ad_rep(self):
""" Assert an ad_rep is created and related to an advertiser, an order,
and a consumer.
"""
email = '[email protected]'
ad_rep = AdRep.objects.create(username=email, email=email,
firestorm_id=100)
self.assertFalse(ad_rep.advertisers().count())
self.assertFalse(ad_rep.orders().count())
self.assertFalse(ad_rep.consumers().count())
# Select an advertiser who may or may not have an ad_rep:
advertiser = ADVERTISER_FACTORY.create_advertiser()
try:
AdRepAdvertiser.objects.create(ad_rep=ad_rep, advertiser=advertiser)
except IntegrityError: # This advertiser already has a rep; change reps.
advertiser.ad_rep_advertiser.ad_rep = ad_rep
advertiser.ad_rep_advertiser.save()
self.assertTrue(ad_rep.advertisers().count())
# Advertisers are a subclassed from Consumer, but relating an advertiser
# to this ad_rep does *not* add the base consumer, too.
self.assertFalse(ad_rep.consumers().count())
order = ORDER_FACTORY.create_order()
AdRepOrder.objects.create(ad_rep=ad_rep, order=order)
self.assertTrue(ad_rep.orders().count())
# Select a consumer who does not have an ad_rep:
consumer = CONSUMER_FACTORY.create_consumer()
AdRepConsumer.objects.create(ad_rep=ad_rep, consumer=consumer)
self.assertTrue(ad_rep.consumers().count())
示例4: test_send_flyers_this_week
# 需要導入模塊: from consumer.factories.consumer_factory import CONSUMER_FACTORY [as 別名]
# 或者: from consumer.factories.consumer_factory.CONSUMER_FACTORY import create_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)
示例5: test_external_click_coupon
# 需要導入模塊: from consumer.factories.consumer_factory import CONSUMER_FACTORY [as 別名]
# 或者: from consumer.factories.consumer_factory.CONSUMER_FACTORY import create_consumer [as 別名]
def test_external_click_coupon(self):
""" Assert external click action gets incremented. """
slot = SLOT_FACTORY.create_slot()
coupon = slot.slot_time_frames.latest('id').coupon
coupon.precise_url = 'http://cnn.com'
coupon.save()
consumer = CONSUMER_FACTORY.create_consumer()
create_consumer_in_session(self, consumer)
self.assemble_session(self.session)
try:
before_clicks = CouponAction.objects.get(
action__id=8, coupon=coupon).count
except CouponAction.DoesNotExist:
before_clicks = 0
response = self.client.get(reverse('external-click-coupon',
kwargs={'coupon_id': coupon.id}))
self.assertEqual(response.status_code, 301)
self.assertEqual(response['location'], coupon.precise_url)
self.assertEqual(CouponAction.objects.get(
action__id=8, coupon=coupon).count, before_clicks + 1)
try:
ConsumerAction.objects.get(
action__id=8, coupon=coupon, consumer=consumer)
except ConsumerAction.DoesNotExist:
self.fail('ConsumerAction not recorded.')
示例6: test_subscriber_reg_with_con
# 需要導入模塊: from consumer.factories.consumer_factory import CONSUMER_FACTORY [as 別名]
# 或者: from consumer.factories.consumer_factory.CONSUMER_FACTORY import create_consumer [as 別名]
def test_subscriber_reg_with_con(self):
""" Post to registration form with valid data, with a consumer already
in session.
"""
consumer = CONSUMER_FACTORY.create_consumer()
create_consumer_in_session(self, consumer)
self.assemble_session(self.session)
post_data = {'mobile_phone_number': '9145550001',
'subscriber_zip_postal': '12550', 'carrier': '2'}
response = self.client.post(reverse('subscriber-registration'),
post_data, follow=True)
# Redirects to local site.
self.assertEqual(response.redirect_chain[0][0], '%s%s' % (
settings.HTTP_PROTOCOL_HOST,
reverse('subscriber-registration-confirmation',
urlconf='urls_local.urls_2')
))
self.assertEqual(response.redirect_chain[0][1], 302)
self.assertContains(response,
'A text message was sent to <strong>(914) 555-0001</strong>')
consumer = Consumer.objects.get(id=consumer.id)
try:
subscriber = Subscriber.objects.get(
mobile_phones__mobile_phone_number='9145550001')
except Subscriber.MultipleObjectsReturned:
self.fail("We created more than one subscriber.")
except Subscriber.DoesNotExist:
self.fail("We did create not a subscriber.")
self.assertEqual(subscriber.site_id, 2)
self.assertEqual(consumer.subscriber, subscriber)
sms_message_sent = SMSMessageSent.objects.latest('id')
self.assertEqual(sms_message_sent.smsto, '9145550001')
self.assertEqual(sms_message_sent.smsmsg[:50],
"10Coupons Alrts: Reply YES to get text coupons (4m")
示例7: test_show_on_site_1_w_session
# 需要導入模塊: from consumer.factories.consumer_factory import CONSUMER_FACTORY [as 別名]
# 或者: from consumer.factories.consumer_factory.CONSUMER_FACTORY import create_consumer [as 別名]
def test_show_on_site_1_w_session(self):
""" Assert view when hit /coupons/ on site 1 with session. """
consumer = CONSUMER_FACTORY.create_consumer()
create_consumer_in_session(self, consumer)
self.assemble_session(self.session)
response = self.client.get('/coupons/')
self.assertEqual(response.status_code, 302)
self.assertEqual(urlparse.urlparse(response['location']).path,
'/hudson-valley/coupons/')
示例8: test_consumer_case_mismatch
# 需要導入模塊: from consumer.factories.consumer_factory import CONSUMER_FACTORY [as 別名]
# 或者: from consumer.factories.consumer_factory.CONSUMER_FACTORY import create_consumer [as 別名]
def test_consumer_case_mismatch(self):
""" Assert case is ignored when checking for preexisting consumer. """
consumer = CONSUMER_FACTORY.create_consumer()
ad_rep_dict = {'email': consumer.email.upper(), 'firestorm_id': 13,
'url': 'upper-cased'}
for field in self.ad_rep_repl_website_fields:
ad_rep_dict[field] = ''
CREATE_OR_UPDATE_AD_REP.run(ad_rep_dict)
self.assertTrue(AdRep.objects.filter(email=consumer.email).count())
示例9: test_apply_review_redirect
# 需要導入模塊: from consumer.factories.consumer_factory import CONSUMER_FACTORY [as 別名]
# 或者: from consumer.factories.consumer_factory.CONSUMER_FACTORY import create_consumer [as 別名]
def test_apply_review_redirect(self):
""" Assert consumer in session gets redirected from trying to view
apply review page.
"""
consumer = CONSUMER_FACTORY.create_consumer()
create_consumer_in_session(self, consumer)
self.assemble_session(self.session)
response = self.client.get(reverse('show-apply-review'), follow=True)
self.assertEqual(response.request['PATH_INFO'],
'/hudson-valley/become-a-sales-rep/')
示例10: test_get_coupons_sub_form
# 需要導入模塊: from consumer.factories.consumer_factory import CONSUMER_FACTORY [as 別名]
# 或者: from consumer.factories.consumer_factory.CONSUMER_FACTORY import create_consumer [as 別名]
def test_get_coupons_sub_form(self):
""" Assert all coupons with consumer in session loads subscriber form
and contest text is not suppressed.
"""
consumer = CONSUMER_FACTORY.create_consumer()
create_consumer_in_session(self, consumer)
self.assemble_session(self.session)
response = self.client.get(reverse('all-coupons'))
self.assertTemplateUsed(response, 'coupon/display_all_coupons.html')
self.assertContains(response, 'Win $10,000!*')
示例11: test_verify_payload_opting
# 需要導入模塊: from consumer.factories.consumer_factory import CONSUMER_FACTORY [as 別名]
# 或者: from consumer.factories.consumer_factory.CONSUMER_FACTORY import create_consumer [as 別名]
def test_verify_payload_opting(self):
""" Assert that payload built with valid consumer email and
opting flag True, adds subscription.
"""
consumer = CONSUMER_FACTORY.create_consumer(subscription_list=False)
self.assertEqual(consumer.email_subscription.count(), 0)
self.build_request(consumer.email)
PAYLOAD_SIGNING.handle_payload(self.request, self.payload,
opting=True)
self.assertEqual(consumer.email_subscription.count(), 1)
示例12: test_reenter_off_site_zip
# 需要導入模塊: from consumer.factories.consumer_factory import CONSUMER_FACTORY [as 別名]
# 或者: from consumer.factories.consumer_factory.CONSUMER_FACTORY import create_consumer [as 別名]
def test_reenter_off_site_zip(self):
""" Assert a consumer in session posts a phone number registered to
another consumer on the all coupons page.
"""
consumer = CONSUMER_FACTORY.create_consumer()
create_consumer_in_session(self, consumer)
subscriber = SUBSCRIBER_FACTORY.create_subscriber()
consumer_2 = CONSUMER_FACTORY.create_consumer()
consumer_2.subscriber = subscriber
consumer_2.save()
mobile_phone_number = subscriber.mobile_phones.all(
)[0].mobile_phone_number
self.assemble_session(self.session)
post_data = {'mobile_phone_number': mobile_phone_number,
'subscriber_zip_postal': '12550', 'carrier': '5'}
response = self.client.post(reverse('all-coupons'), post_data)
self.assertTemplateUsed(response, 'coupon/display_all_coupons.html')
self.assertTemplateUsed(response,
'include/dsp/dsp_pricing_unlocked.html')
示例13: test_show_deny_consumer
# 需要導入模塊: from consumer.factories.consumer_factory import CONSUMER_FACTORY [as 別名]
# 或者: from consumer.factories.consumer_factory.CONSUMER_FACTORY import create_consumer [as 別名]
def test_show_deny_consumer(self):
""" Assert offer process with missing advertiser redirects to advertiser
registration form.
"""
consumer = CONSUMER_FACTORY.create_consumer()
create_consumer_in_session(self, consumer)
self.assemble_session(self.session)
response = self.client.get(reverse('add-offer'), follow=True)
self.assertEquals(str(response.request['PATH_INFO']),
'/hudson-valley/create-coupon/')
示例14: test_already_bouncing
# 需要導入模塊: from consumer.factories.consumer_factory import CONSUMER_FACTORY [as 別名]
# 或者: from consumer.factories.consumer_factory.CONSUMER_FACTORY import create_consumer [as 別名]
def test_already_bouncing(self):
""" Assert request for a consumer already marked as bouncing
returns a status message 1.
"""
consumer = CONSUMER_FACTORY.create_consumer()
email = consumer.email
consumer.nomail_reason.add(1)
response = self.client.get(reverse('report-bouncing',
kwargs={'email_string':email, 'nomail_reason':1}))
self.assertEqual(response.status_code, 200)
self.assertContains(response, '1 re: %s bouncing' % email)
示例15: test_show_sign_in_consumer
# 需要導入模塊: from consumer.factories.consumer_factory import CONSUMER_FACTORY [as 別名]
# 或者: from consumer.factories.consumer_factory.CONSUMER_FACTORY import create_consumer [as 別名]
def test_show_sign_in_consumer(self):
""" Test sign in page for consumer in session. """
consumer = CONSUMER_FACTORY.create_consumer()
create_consumer_in_session(self, consumer)
self.assemble_session(self.session)
response = self.client.get(reverse('sign-in'))
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'display_sign_in.html')
self.assertContains(response, 'Welcome back! Sign in with your email')
self.assertNotContains(response, 'create a coupon</a>')
self.assertContains(response, consumer.email)