本文整理汇总了Python中coupon.factories.coupon_factory.COUPON_FACTORY.normalize_coupon_locations方法的典型用法代码示例。如果您正苦于以下问题:Python COUPON_FACTORY.normalize_coupon_locations方法的具体用法?Python COUPON_FACTORY.normalize_coupon_locations怎么用?Python COUPON_FACTORY.normalize_coupon_locations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coupon.factories.coupon_factory.COUPON_FACTORY
的用法示例。
在下文中一共展示了COUPON_FACTORY.normalize_coupon_locations方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_loc_list_many
# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import normalize_coupon_locations [as 别名]
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))
示例2: test_get_loc_list_two
# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import normalize_coupon_locations [as 别名]
def test_get_loc_list_two(self):
""" Assert get_location_list when there are less then or equal to three
locations returns all locations concatenated with "&".
"""
coupon = COUPON_FACTORY.create_coupon_many_locations(
business_location_count=2)
COUPON_FACTORY.normalize_coupon_locations(coupon)
[location_0, location_1] = coupon.location.all()
string_0 = '%s, %s' % (location_0.location_city,
location_0.location_state_province)
string_1 = '%s, %s' % (location_1.location_city,
location_1.location_state_province)
display_location, display_city = coupon.get_location_string()
# Order of locations is not determined:
self.assertTrue(display_location == [location_0.location_city, string_1]
or display_location == [location_1.location_city, string_0])
self.assertEqual(display_city, string_0)
示例3: test_view_multi_location
# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import normalize_coupon_locations [as 别名]
def test_view_multi_location(self):
""" Assert that the coupon meta tag has all locations listed in it. """
coupon = COUPON_FACTORY.create_coupon_many_locations(
business_location_count=2, coupon_location_count=2)
COUPON_FACTORY.normalize_coupon_locations(coupon)
SLOT_FACTORY.create_slot(coupon=coupon)
consumer = CONSUMER_FACTORY.create_consumer()
create_consumer_in_session(self, consumer)
# Assert that meta description tag lists all locations.
self.assemble_session(self.session)
response = self.client.get(reverse('view-single-coupon',
kwargs={'slug': coupon.slug(), 'coupon_id': coupon.id}))
self.assertEqual(response.status_code, 200)
LOG.debug('-----test_view_multi_location Page Content Start-----')
LOG.debug(response.content[:800])
LOG.debug('-----test_view_multi_location Page Content End-----')
locations = coupon.location.all()
self.assertTrue(
'"description" content="Get %s %s at %s in %s and %s, %s' % (
coupon.offer.headline.title(), coupon.offer.qualifier.title(),
coupon.offer.business.business_name,
locations[0].location_city, locations[1].location_city,
locations[1].location_state_province,)
in response.content[:800])