本文整理汇总了Python中coupon.factories.coupon_factory.COUPON_FACTORY.create_coupon_many_locations方法的典型用法代码示例。如果您正苦于以下问题:Python COUPON_FACTORY.create_coupon_many_locations方法的具体用法?Python COUPON_FACTORY.create_coupon_many_locations怎么用?Python COUPON_FACTORY.create_coupon_many_locations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coupon.factories.coupon_factory.COUPON_FACTORY
的用法示例。
在下文中一共展示了COUPON_FACTORY.create_coupon_many_locations方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_loc_list_many
# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupon_many_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_blank_city_ignored
# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupon_many_locations [as 别名]
def test_blank_city_ignored(self):
""" Assert for a coupon with two locations, one with a blank city."""
coupon = COUPON_FACTORY.create_coupon_many_locations(
business_location_count=2, coupon_location_count=2)
(location_1, location_2) = coupon.location.all()
location_1.location_city = ''
location_1.save()
location = ALL_COUPONS.build_coupon_location_list([coupon.id])
self.assertEquals(len(location), 1)
# City becomes proper cased.
self.assertEquals(location[coupon.id],
[location_2.location_city.title()])
示例3: test_coupon_location_w_dupes
# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupon_many_locations [as 别名]
def test_coupon_location_w_dupes(self):
""" Assert the build_coupon_locations method for duplicate cities. """
coupon = COUPON_FACTORY.create_coupon_many_locations(
business_location_count=3, coupon_location_count=3)
locations = list(coupon.location.all())
locations[1].location_city = locations[0].location_city
locations[1].save()
locations = ALL_COUPONS.build_coupon_location_list([coupon.id])
for key in locations:
temp = set()
for x in locations[key]:
if x in temp:
self.fail("Exclude duplicates in coupon location list.")
else:
temp.add(x)
示例4: test_get_loc_list_two
# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupon_many_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)
示例5: test_build_coupon_locations
# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupon_many_locations [as 别名]
def test_build_coupon_locations(self):
""" Assert coupon locations are read, parsed and formatted correctly.
"""
coupon_1 = COUPON_FACTORY.create_coupon()
coupon_1.location.clear()
coupon_2 = COUPON_FACTORY.create_coupon_many_locations(
business_location_count=2, coupon_location_count=2)
location = ALL_COUPONS.build_coupon_location_list(
[coupon_1.id, coupon_2.id])
# Assert returned dict has one key; first coupon has no locations.
LOG.debug('location: %s' % location)
self.assertEquals(len(location), 1)
# Check string formatting of locations.
locations = coupon_2.location.all()
# First city becomes proper cased.
# It is not determined which order the cities will be returned in:
try:
self.assertEquals(location[coupon_2.id],
[locations[0].location_city.title(),
locations[1].location_city])
except AssertionError:
self.assertEquals(location[coupon_2.id],
[locations[1].location_city.title(),
locations[0].location_city])
示例6: test_view_multi_location
# 需要导入模块: from coupon.factories.coupon_factory import COUPON_FACTORY [as 别名]
# 或者: from coupon.factories.coupon_factory.COUPON_FACTORY import create_coupon_many_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])