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


Python coupon_factory.COUPON_FACTORY类代码示例

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


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

示例1: test_get_loc_list_many

 def test_get_loc_list_many(self):
     """ Assert get_location_list when there are 8 locations returns all
     locations concatenated with a comma.
     """
     coupon = COUPON_FACTORY.create_coupon_many_locations(
         business_location_count=8)
     COUPON_FACTORY.normalize_coupon_locations(coupon)
     locations = coupon.location.all()
     display_location, display_city = coupon.get_location_string()
     LOG.debug('display_location: %s' % display_location)
     LOG.debug('display_city: %s' % display_city)
     LOG.debug('locations: %s' %
         [(loc.location_city, loc.location_state_province)
         for loc in locations])
     self.assertEqual(display_location, [
         locations[0].location_city,
         locations[1].location_city,
         locations[2].location_city,
         locations[3].location_city,
         locations[4].location_city,
         locations[5].location_city,
         locations[6].location_city,
         '%s, %s' % (locations[7].location_city,
             locations[7].location_state_province)])
     self.assertEqual(display_city, '%s, %s' % (
         locations[0].location_city, locations[0].location_state_province))
开发者ID:wcirillo,项目名称:ten,代码行数:26,代码来源:test_coupon_models.py

示例2: setUpClass

    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,代码行数:34,代码来源:test_service.py

示例3: test_business_in_flyer

 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,代码行数:11,代码来源:test_flyer.py

示例4: test_record_action

 def test_record_action(self):
     """ Assert an action is recorded. """
     coupons = COUPON_FACTORY.create_coupons(create_count=2)
     record_action = RecordAction()
     now = datetime.datetime.now()
     record_action.run(1, coupons[0].id)
     action_count = CouponAction.objects.get(
         action__id=1, coupon=coupons[0]).count
     LOG.debug('action_count = %s' % action_count)
     record_action.run(1, coupons[0].id)
     new_action_count = CouponAction.objects.get(
         action__id=1, coupon=coupons[0]).count
     LOG.debug('new_action_count = %s' % new_action_count)
     self.assertEqual(action_count + 1, new_action_count)
     coupon_ids = tuple([coupon.id for coupon in coupons])
     record_action_multiple_coupons(1, coupon_ids)
     newer_action_count = CouponAction.objects.get(
         action__id=1, coupon=coupons[0]).count
     LOG.debug('newer_action_count = %s' % newer_action_count)
     self.assertEqual(new_action_count + 1, newer_action_count)
     consumer = Consumer.objects.create(consumer_create_datetime=now)
     record_action_multiple_coupons(1, coupon_ids, consumer.id)
     newest_action_count = CouponAction.objects.get(
         action__id=1, coupon=coupons[0]).count
     LOG.debug('newest_action_count = %s' % newest_action_count)
     consumer_action = ConsumerAction.objects.get(
         action__id=1, coupon=coupons[0], consumer=consumer)
     self.assertTrue(consumer_action)
     LOG.debug('consumer_action = %s' % consumer_action)
开发者ID:wcirillo,项目名称:ten,代码行数:29,代码来源:test_tasks.py

示例5: test_create_success_no_custom

 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,代码行数:34,代码来源:test_restrictions_views.py

示例6: test_valid_days_on_get

 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,代码行数:30,代码来源:test_restrictions_views.py

示例7: test_get_biz_profile_none

 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,代码行数:7,代码来源:test_model.py

示例8: 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

示例9: create_slot_family

 def create_slot_family(self, create_count=10):
     """ Create a parent with 1 to 9 children to ensure a full slot family
     has been established.
     """
     children_list = []
     offer_list = OFFER_FACTORY.create_offers(
         create_business=True,
         create_count=create_count)
     for index, offer in enumerate(offer_list):
         coupon = COUPON_FACTORY.create_coupons(offer=offer)[0]
         if index == 0:
             slot = self._create(business=coupon.offer.business)
             parent_slot = slot
             SLOT_TIME_FRAME_FACTORY.create_slot_time_frame(
                 slot=parent_slot,
                 coupon=coupon)
         else:
             child_slot = self._create(business=coupon.offer.business,
                 parent_slot=parent_slot)
             SLOT_TIME_FRAME_FACTORY.create_slot_time_frame(
                 slot=child_slot, coupon=coupon)
             children_list.append(child_slot)
     family_dict =  {'parent':parent_slot, 'children':children_list}
     children_list.append(parent_slot)
     slot_list = children_list
     return family_dict, slot_list
开发者ID:wcirillo,项目名称:ten,代码行数:26,代码来源:slot_factory.py

示例10: test_fail_create_missing_fields

    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,代码行数:30,代码来源:test_restrictions_views.py

示例11: test_check_coupon_code_good

 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,代码行数:7,代码来源:test_coupon_code.py

示例12: test_create_mult_coupon_codes

 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,代码行数:7,代码来源:test_coupon_code.py

示例13: test_get_coords_list_valid

 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,代码行数:8,代码来源:test_coupon_models.py

示例14: test_record_action_bad_consumer

 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,代码行数:8,代码来源:test_tasks.py

示例15: test_get_active_coupon

 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,代码行数:8,代码来源:test_slot_models.py


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