本文整理汇总了Python中coupon.factories.coupon_factory.COUPON_FACTORY.create_coupons方法的典型用法代码示例。如果您正苦于以下问题:Python COUPON_FACTORY.create_coupons方法的具体用法?Python COUPON_FACTORY.create_coupons怎么用?Python COUPON_FACTORY.create_coupons使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coupon.factories.coupon_factory.COUPON_FACTORY
的用法示例。
在下文中一共展示了COUPON_FACTORY.create_coupons方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_slot_family
# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupons [as 别名]
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
示例2: test_record_action
# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupons [as 别名]
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)
示例3: test_max_ten_coupons_per_flyer
# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupons [as 别名]
def test_max_ten_coupons_per_flyer(self):
""" Assert a flyer may have at most 10 coupons. """
flyer = Flyer.objects.create(site_id=3)
coupons = COUPON_FACTORY.create_coupons(create_count=11)
count = 0
for coupon in coupons:
if append_coupon_to_flyer(flyer, coupon):
count += 1
self.assertEqual(count, 10)
示例4: test_record_act_mult_bad_con
# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupons [as 别名]
def test_record_act_mult_bad_con(self):
""" Assert action for multiple coupons is not incremented when a bad
consumer_id is passed.
"""
coupons = COUPON_FACTORY.create_coupons(create_count=2)
coupon_ids = tuple([coupon.id for coupon in coupons])
try:
record_action_multiple_coupons(1, coupon_ids, 999999)
except IntegrityError as error:
self.fail('IntegrityError thrown, not caught: %s' % error)
示例5: test_diff_bizz_no_business
# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupons [as 别名]
def test_diff_bizz_no_business(self):
""" POST a different Business that has no match in session.
advertiser->business0->offer0->coupon0('In Progress')
advertiser->business1->offer0->coupon0('Paid')('Slot Expired')
advertiser->business1->offer0->coupon1('In Progress')
"""
business = BUSINESS_FACTORY.create_business(advertiser=self.advertiser)
offer = OFFER_FACTORY.create_offer(business=business)
coupon_list = COUPON_FACTORY.create_coupons(offer=offer, create_count=2)
coupon0 = coupon_list[0]
coupon1 = coupon_list[1]
coupon1.coupon_type = CouponType.objects.get(id=1)
coupon1.save()
self.prep_slot(coupon0, coupon0)
build_advertiser_session(self, self.advertiser)
self.assemble_session(self.session)
self.setup_post_data(self.advertiser, location_count=1)
self.post_data['business_name'] = 'This Will Not Match'
self.assemble_session(self.session)
pre_business_count = self.advertiser.businesses.all().count()
response = self.client.post(
reverse('preview-coupon'), self.post_data, follow=True
)
self.assertEqual(response.status_code, 200)
self.advertiser = Advertiser.objects.get(id=self.advertiser.id)
post_business_count = self.advertiser.businesses.all().count()
self.assertEqual(pre_business_count, post_business_count)
self.assertEqual(str(response.request['PATH_INFO']),
'/hudson-valley/create-coupon/checkout/')
self.assertContains(response, "frm_checkout_coupon_purchase")
self.assert_session_keys_current(
current_biz=(1, 0), current_offer=(0, 0), current_coupon=(1, 0))
self.assertNotEqual(self.post_data['business_name'],
self.client.session['consumer']['advertiser']['business'][
1]['business_name'])
self.assert_session_update(business_name=self.post_data['business_name'],
headline=self.post_data['headline'],
qualifier=self.post_data['qualifier'], coupon_type_id=1)
new_coupon_id = self.client.session['consumer']['advertiser'][
'business'][0]['offer'][0]['coupon'][0]['coupon_id']
self.assert_new_coupon(new_coupon_id, coupon_id=self.coupon.id,
coupon_type_id=1, offer_id=self.coupon.offer.id,
headline=self.post_data['headline'],
qualifier=self.post_data['qualifier'],
business_id=self.coupon.offer.business.id,
business_name=self.post_data['business_name'])
示例6: test_ajax
# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupons [as 别名]
def test_ajax(self):
""" Assert ajax contains data for coupons of advertiser's businesses.
"""
ad_rep = AD_REP_FACTORY.create_ad_rep()
coupon_list = COUPON_FACTORY.create_coupons(create_count=3)
count = 1
for coupon in coupon_list:
AdRepAdvertiser.objects.create(ad_rep=ad_rep,
advertiser=coupon.offer.business.advertiser)
for action_id in [1, 2, 3, 7]:
CouponAction.objects.create(coupon=coupon,
action_id=action_id, count=count)
count += 1
self.client.login(username='super', password='secret')
post_data = {'id': ad_rep.firestorm_id,
'business_id': '0'}
# The the view needs the POST dict.
response = self.client.post(reverse('admin-advertiser-stats',
kwargs={'ad_rep_id': str(ad_rep.id)}),
post_data)
LOG.debug(coupon_list)
LOG.debug(response.content)
for coupon in coupon_list:
self.assertContains(response,
'"headline": "%s"' % coupon.offer.headline)
self.assertContains(response,
'"qualifier": "%s"' % coupon.offer.qualifier)
self.assertContains(response, '"views": [1]')
self.assertContains(response, '"clicks": [2]')
self.assertContains(response, '"prints": [3]')
self.assertContains(response, '"shares": [4]')
self.assertContains(response, '"views": [5]')
self.assertContains(response, '"clicks": [6]')
self.assertContains(response, '"prints": [7]')
self.assertContains(response, '"shares": [8]')
self.assertContains(response, '"views": [9]')
self.assertContains(response, '"clicks": [10]')
self.assertContains(response, '"prints": [11]')
self.assertContains(response, '"shares": [12]')
示例7: test_check_coupon_code_bad
# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupons [as 别名]
def test_check_coupon_code_bad(self):
""" Assert an invalid code for a coupon fails checking. """
coupons = COUPON_FACTORY.create_coupons(create_count=2)
coupon_code = create_coupon_code(coupons[0])
used_count = check_coupon_code(coupons[1], coupon_code.code)
self.assertEqual(used_count, -1)