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


Python COUPON_FACTORY.create_coupon方法代码示例

本文整理汇总了Python中coupon.factories.coupon_factory.COUPON_FACTORY.create_coupon方法的典型用法代码示例。如果您正苦于以下问题:Python COUPON_FACTORY.create_coupon方法的具体用法?Python COUPON_FACTORY.create_coupon怎么用?Python COUPON_FACTORY.create_coupon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在coupon.factories.coupon_factory.COUPON_FACTORY的用法示例。


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

示例1: setUpClass

# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupon [as 别名]
    def setUpClass(cls):
        """ Set up coupons to be retrieved for the following tests. """
        super(TestCouponPerformance, cls).setUpClass()
        coupon = COUPON_FACTORY.create_coupon()
        expiring_coupon = COUPON_FACTORY.create_coupon()
        expiring_coupon.expiration_date = (
            datetime.date.today() + datetime.timedelta(1))
        expiring_coupon.save()
        coupon_w_locations = COUPON_FACTORY.create_coupons_many_locations()[0]
        second_coupon_this_biz = COUPON_FACTORY.create_coupon()
        offer = second_coupon_this_biz.offer
        offer.business = expiring_coupon.offer.business
        offer.save()
        SLOT_FACTORY.create_slot(coupon=coupon)
        SLOT_FACTORY.create_slot(coupon=expiring_coupon)
        SLOT_FACTORY.create_slot(coupon=coupon_w_locations)
        SLOT_FACTORY.create_slot(coupon=second_coupon_this_biz)
        
        # Move coupon to share advertiser with  second_coupon_this_biz.
        business = coupon.offer.business
        business.advertiser = second_coupon_this_biz.offer.business.advertiser
        business.save()

        # Relate all of these businesses except one to these coupons advertisers.
        cls.ad_rep = AD_REP_FACTORY.create_ad_rep()
        AdRepAdvertiser.objects.create(ad_rep=cls.ad_rep, 
            advertiser=expiring_coupon.offer.business.advertiser)
        AdRepAdvertiser.objects.create(ad_rep=cls.ad_rep, 
            advertiser=coupon_w_locations.offer.business.advertiser)
        # Set vars for testing:
        cls.advertiser_not_related = coupon.offer.business.advertiser
        cls.expiring_coupon = expiring_coupon
        cls.coupon_w_locations = coupon_w_locations
        cls.business_w_2_coupons = second_coupon_this_biz
开发者ID:wcirillo,项目名称:ten,代码行数:36,代码来源:test_service.py

示例2: test_business_in_flyer

# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupon [as 别名]
 def test_business_in_flyer(self):
     """ Assert a coupon is not appends to the flyer if its business already
     is in the flyer.
     """
     flyer = Flyer.objects.create(site_id=3)
     coupon = COUPON_FACTORY.create_coupon()
     coupon_2 = COUPON_FACTORY.create_coupon(offer=coupon.offer)
     FlyerCoupon.objects.create(flyer=flyer, coupon=coupon)
     need_more, skipped = conditionally_append_coupon(flyer, coupon_2)
     self.assertTrue(need_more)
     self.assertTrue(skipped)
开发者ID:wcirillo,项目名称:ten,代码行数:13,代码来源:test_flyer.py

示例3: test_check_coupon_code_good

# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupon [as 别名]
 def test_check_coupon_code_good(self):
     """ Assert a valid code for a coupon is created, checked and not used.
     """
     coupon = COUPON_FACTORY.create_coupon()
     coupon_code = create_coupon_code(coupon)
     used_count = check_coupon_code(coupon, coupon_code.code)
     self.assertEqual(used_count, 0)
开发者ID:wcirillo,项目名称:ten,代码行数:9,代码来源:test_coupon_code.py

示例4: test_send_offer_130_ad_rep

# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupon [as 别名]
 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,代码行数:31,代码来源:test_warm_leads_email_task.py

示例5: test_create_success_no_custom

# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupon [as 别名]
 def test_create_success_no_custom(self):
     """ Test show_create_restrictions view with posted form submission so it
     will save the coupon restrictions to the database. Custom_restrictions 
     aresubmitted in the form blank and should not be recorded with 
     default_restrictions.
     Assert that when no ad rep is in session the product_list is populated
     with monthly pricing option.
     """
     coupon = COUPON_FACTORY.create_coupon()
     advertiser = coupon.offer.business.advertiser
     build_advertiser_session(self, advertiser)
     self.assemble_session(self.session)
     # Default restriction_0 = one coupon per person per visit.
     response = self.client.post(reverse('create-restrictions'), 
         data={"is_redeemed_by_sms" : 1,
               "default_restrictions" : [2, 3, 5, 7],
               "custom_restrictions" : ""}, 
         follow=True) 
     coupon = SINGLE_COUPON.get_coupon(self)
     self.assertEqual(coupon.default_restrictions.all().count(), 4, 
         "Default restrictions supplied for coupon interpreted incorrectly")
     self.assertEqual(str(response.request['PATH_INFO']), 
         '/hudson-valley/create-coupon/checkout/')
     self.assertContains(response, 'frm_checkout_coupon_purchase')
     # Validate selections made are displayed as checked in preview.
     all_restrictions = DefaultRestrictions.objects.all()
     self.assertNotContains(response, all_restrictions.get(id=1).restriction)
     self.assertContains(response, all_restrictions.get(id=2).restriction)
     self.assertContains(response, all_restrictions.get(id=3).restriction)
     self.assertNotContains(response, all_restrictions.get(id=4).restriction)
     self.assertContains(response, all_restrictions.get(id=5).restriction)
     self.assertNotContains(response, all_restrictions.get(id=6).restriction)
     self.assertContains(response, all_restrictions.get(id=7).restriction)
     self.assertEqual(self.client.session['product_list'][0][0], 2)
开发者ID:wcirillo,项目名称:ten,代码行数:36,代码来源:test_restrictions_views.py

示例6: test_fail_create_missing_fields

# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupon [as 别名]
    def test_fail_create_missing_fields(self):
        """ Test process_create_restrictions from form submission missing
        required fields forcing the view to reload current form 
        selections/inputs.
        """
        coupon = COUPON_FACTORY.create_coupon()
        advertiser = coupon.offer.business.advertiser
        build_advertiser_session(self, advertiser)
        self.assemble_session(self.session)
        # Default restriction_0 = one coupon per person per visit.
        response = self.client.post(reverse('create-restrictions'), 
            data={"default_restrictions" : [2, 3]}) 
        # Check to ensure previous selections still loaded.
        self.assertContains(response, 
            '"checked" type="checkbox" name="default_restrictions" value="2"')
        self.assertContains(response, 
            '"checked" type="checkbox" name="default_restrictions" value="3"')
        self.assertContains(response, 
            '<input type="checkbox" name="default_restrictions" value="4"')
        self.assertContains(response, 
            '<input type="checkbox" name="default_restrictions" value="5"')
        self.assertContains(response, 
            '<input type="checkbox" name="default_restrictions" value="6"')
        self.assertContains(response, 
            '<input type="checkbox" name="default_restrictions" value="7"')
        self.assertContains(response, 
            '<input type="checkbox" name="default_restrictions" value="1"')

        self.assertEqual(str(response.request['PATH_INFO']), 
            '/hudson-valley/create-coupon/restrictions/')
开发者ID:wcirillo,项目名称:ten,代码行数:32,代码来源:test_restrictions_views.py

示例7: test_valid_days_on_get

# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupon [as 别名]
 def test_valid_days_on_get(self):
     """ Assert all days are selected and form is correct. """
     coupon = COUPON_FACTORY.create_coupon()
     advertiser = coupon.offer.business.advertiser
     coupon.is_valid_monday = True
     coupon.is_valid_tuesday = True
     coupon.is_valid_wednesday = True
     coupon.is_valid_thursday = True
     coupon.is_valid_friday = True
     coupon.is_valid_saturday = True
     coupon.is_valid_sunday = True
     coupon.save()
     build_advertiser_session(self, advertiser)
     self.assemble_session(self.session)
     response = self.client.get(reverse('create-restrictions'))
     self.assertContains(response,
         'id="id_is_valid_monday" checked="checked"')
     self.assertContains(response,
         'id="id_is_valid_tuesday" checked="checked"')
     self.assertContains(response,
         'id="id_is_valid_wednesday" checked="checked"')
     self.assertContains(response,
         'id="id_is_valid_thursday" checked="checked"')
     self.assertContains(response,
         'id="id_is_valid_friday" checked="checked"')
     self.assertContains(response,
         'id="id_is_valid_saturday" checked="checked"')
     self.assertContains(response,
         'id="id_is_valid_sunday" checked="checked"')
     self.assertContains(response, "Offer good 7 days a week.")
开发者ID:wcirillo,项目名称:ten,代码行数:32,代码来源:test_restrictions_views.py

示例8: test_get_biz_profile_none

# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupon [as 别名]
 def test_get_biz_profile_none(self):
     """ 
     Test business method that returns business profile description None as 
     default (from coupon)
     """
     coupon = COUPON_FACTORY.create_coupon()
     self.assertEqual(coupon.offer.business.get_business_description(), '')
开发者ID:wcirillo,项目名称:ten,代码行数:9,代码来源:test_model.py

示例9: test_create_mult_coupon_codes

# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupon [as 别名]
 def test_create_mult_coupon_codes(self):
     """ Assert multiple codes are created for a coupon. """
     coupon = COUPON_FACTORY.create_coupon()
     preexisting_count = CouponCode.objects.filter(coupon=coupon).count()
     create_multiple_coupon_codes(coupon, 6)
     new_count = CouponCode.objects.filter(coupon=coupon).count()
     self.assertEqual(preexisting_count + 6, new_count)
开发者ID:wcirillo,项目名称:ten,代码行数:9,代码来源:test_coupon_code.py

示例10: test_get_active_coupon

# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupon [as 别名]
 def test_get_active_coupon(self):
     """ Assert the current coupon of a slot is selected. """
     coupon = COUPON_FACTORY.create_coupon()
     slot = SLOT_FACTORY.create_slot(coupon=coupon)
     future_date = datetime.date.today() + datetime.timedelta(weeks=1)
     coupon.expiration_date = future_date
     coupon.save()
     self.assertEqual(slot.get_active_coupon(), coupon)
开发者ID:wcirillo,项目名称:ten,代码行数:10,代码来源:test_slot_models.py

示例11: test_record_action_bad_consumer

# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupon [as 别名]
 def test_record_action_bad_consumer(self):
     """ Assert action is not incremented when a bad consumer_id is passed.
     """
     coupon = COUPON_FACTORY.create_coupon()
     try:
         RecordAction().run(1, coupon.id, 999999)
     except IntegrityError:
         self.fail('IntegrityError thrown, not caught.')
开发者ID:wcirillo,项目名称:ten,代码行数:10,代码来源:test_tasks.py

示例12: setUp

# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupon [as 别名]
 def setUp(self):
     super(PreviewEditTestCase, self).setUp()
     self.coupon = COUPON_FACTORY.create_coupon()
     self.coupon.coupon_type = CouponType.objects.get(id=1)
     self.coupon.save()
     self.location = self.coupon.offer.business.locations.all()[0]
     self.advertiser = self.coupon.offer.business.advertiser
     self.request_data = None  
开发者ID:wcirillo,项目名称:ten,代码行数:10,代码来源:test_cases.py

示例13: test_get_active_coupon_bad

# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupon [as 别名]
 def test_get_active_coupon_bad(self):
     """ Assert a slot with an expired coupon returns None. """
     coupon = COUPON_FACTORY.create_coupon()
     slot = SLOT_FACTORY.create_slot(coupon=coupon)
     coupon.expiration_date = (datetime.date.today() -
         datetime.timedelta(weeks=1))
     coupon.save()
     self.assertEqual(slot.get_active_coupon(), None)
开发者ID:wcirillo,项目名称:ten,代码行数:10,代码来源:test_slot_models.py

示例14: test_get_coords_list_valid

# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupon [as 别名]
 def test_get_coords_list_valid(self):
     """ Assert the get_location_coords_list method returns all location
     coords for a given coupon.
     """
     coupon = COUPON_FACTORY.create_coupon()
     coords_list = coupon.get_location_coords_list()
     self.assertAlmostEqual(int(float(coords_list[0][0])), -73)
     self.assertAlmostEqual(int(float(coords_list[0][1])), 41)
开发者ID:wcirillo,项目名称:ten,代码行数:10,代码来源:test_coupon_models.py

示例15: test_get_loc_list_one

# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupon [as 别名]
 def test_get_loc_list_one(self):
     """ Assert get_location_list when there is one location. """
     coupon = COUPON_FACTORY.create_coupon()
     location = coupon.location.all()[0]
     display_location, display_city = coupon.get_location_string()
     string = '%s, %s' % (location.location_city,
         location.location_state_province)
     self.assertEqual(display_location, [string])
     self.assertEqual(display_city, string)
开发者ID:wcirillo,项目名称:ten,代码行数:11,代码来源:test_coupon_models.py


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