本文整理汇总了Python中stoqlib.domain.address.CityLocation.city_code方法的典型用法代码示例。如果您正苦于以下问题:Python CityLocation.city_code方法的具体用法?Python CityLocation.city_code怎么用?Python CityLocation.city_code使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stoqlib.domain.address.CityLocation
的用法示例。
在下文中一共展示了CityLocation.city_code方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_or_create
# 需要导入模块: from stoqlib.domain.address import CityLocation [as 别名]
# 或者: from stoqlib.domain.address.CityLocation import city_code [as 别名]
def test_get_or_create(self):
loc = CityLocation.get_or_create(self.store, u'City',
u'State', u'Country')
self.failUnless(loc)
self.assertEqual(loc.city, u'City')
self.assertEqual(loc.state, u'State')
self.assertEqual(loc.country, u'Country')
loc2 = CityLocation.get_or_create(self.store, u'city',
u'state', u'country')
self.failUnless(loc2)
self.assertEqual(loc2.city, u'City')
self.assertEqual(loc2.state, u'State')
self.assertEqual(loc2.country, u'Country')
self.assertEqual(loc2, loc)
location = CityLocation.get_or_create(self.store, u'São Carlos',
u'SP', u'Brazil')
for city, state, country in [
(u'sao carlos', u'SP', u'Brazil'),
(u'Sao carlos', u'SP', u'Brazil'),
(u'São carlos', u'SP', u'Brazil'),
(u'sao Carlos', u'SP', u'Brazil'),
(u'sao Carlos', u'sp', u'Brazil'),
(u'sao Carlos', u'sp', u'brazil'),
(u'sao Carlos', u'Sp', u'brazil')]:
self.assertEqual(CityLocation.get_or_create(self.store, city,
state, country),
location)
loc2 = CityLocation(store=self.store)
loc2.city = u'Sao Carlos'
loc2.state = u'SP'
loc2.country = u'Brazil'
loc2.city_code = 00000
location = CityLocation.get_or_create(self.store, u'São Carlos',
u'SP', u'Brazil')
self.assertEquals(location.city_code, 3548906)
loc3 = CityLocation(store=self.store)
loc3.city = u'City ABC'
loc3.state = u'SP'
loc3.country = u'Brazil'
loc3.city_code = None
loc4 = CityLocation(store=self.store)
loc4.city = u'City ABĆ'
loc4.state = u'SP'
loc4.country = u'Brazil'
loc4.city_code = None
location = CityLocation.get_or_create(self.store, u'City ABC',
u'SP', u'Brazil')
self.assertNotEquals(location, loc4)
loc4.city_code = 13560
location = CityLocation.get_or_create(self.store, u'City ABC',
u'SP', u'Brazil')
self.assertEquals(location, loc4)
for city, state, country in [(u'Sao', u'SP', 'Brazil'),
(u'carlos', decimal.Decimal(8), u'Brazil')]:
with self.assertRaises(TypeError):
CityLocation.get_or_create(self.store, city, state, country)