本文整理汇总了Python中coupon.factories.coupon_factory.COUPON_FACTORY.create_coupons_many_locations方法的典型用法代码示例。如果您正苦于以下问题:Python COUPON_FACTORY.create_coupons_many_locations方法的具体用法?Python COUPON_FACTORY.create_coupons_many_locations怎么用?Python COUPON_FACTORY.create_coupons_many_locations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coupon.factories.coupon_factory.COUPON_FACTORY
的用法示例。
在下文中一共展示了COUPON_FACTORY.create_coupons_many_locations方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUpClass
# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupons_many_locations [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
示例2: test_build_coup_loc_confirm
# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupons_many_locations [as 别名]
def test_build_coup_loc_confirm(self):
""" Confirm that locations pulled for coupon belong to THIS coupon. """
coupons = COUPON_FACTORY.create_coupons_many_locations(create_count=3,
business_location_count=3, coupon_location_count=3)
locations = ALL_COUPONS.build_coupon_location_list(
[coupon.id for coupon in coupons])
test_list = []
for loc in coupons[0].location.all():
test_list.append(loc.location_city.lower())
self.assertEqual(len(test_list), len(locations[coupons[0].id]))
for loc in locations[coupons[0].id]:
if loc.lower() not in test_list:
self.fail('Invalid location in build_coupon_location result.')