本文整理汇总了Python中stoqlib.domain.address.CityLocation.get_cities_by方法的典型用法代码示例。如果您正苦于以下问题:Python CityLocation.get_cities_by方法的具体用法?Python CityLocation.get_cities_by怎么用?Python CityLocation.get_cities_by使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stoqlib.domain.address.CityLocation
的用法示例。
在下文中一共展示了CityLocation.get_cities_by方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testGetCitiesBy
# 需要导入模块: from stoqlib.domain.address import CityLocation [as 别名]
# 或者: from stoqlib.domain.address.CityLocation import get_cities_by [as 别名]
def testGetCitiesBy(self):
location = CityLocation.get_or_create(self.store, u'Sao Carlos',
u'SP', u'Brazil')
for state, country in [
(u'SP', u'Brazil'),
(u'Sp', u'brazil'),
(u'SP', u'brazil'),
(u'sp', u'Brazil'),
(u'sp', u'BraZIL'),
(None, u'Brazil'),
(u'SP', None),
(None, None),
]:
self.assertTrue(location.city in
CityLocation.get_cities_by(self.store,
state=state,
country=country))
for state, country in [
(u'SP', u'Brazi'),
(u'RJ', u'Brazil'),
(u'RJ', None),
(u'BA', None),
(u'SP', u'Albânia'),
]:
self.assertFalse(location.city in
CityLocation.get_cities_by(self.store,
state=state,
country=country))
# Make sure no duplicates are returned
CityLocation.get_or_create(self.store, u'Sao Carlos', u'SP', u'BR')
CityLocation.get_or_create(self.store, u'Sao Carlos', u'SP', u'BR_')
CityLocation.get_or_create(self.store, u'Sao Carlos', u'SP', u'BR__')
cities = list(CityLocation.get_cities_by(self.store, state=u'SP'))
self.assertEqual(len(cities), len(set(cities)))
示例2: _prefill_cities
# 需要导入模块: from stoqlib.domain.address import CityLocation [as 别名]
# 或者: from stoqlib.domain.address.CityLocation import get_cities_by [as 别名]
def _prefill_cities(self, force=False):
completion = self.city.get_completion()
if not completion:
# Completion wasn't set yet
return
if len(completion.get_model()) and not force:
return
self.city.prefill([]) # mimic missing .clear method
cities = CityLocation.get_cities_by(self.store,
state=self.model.state,
country=self.model.country)
self.city.prefill(list(cities))