当前位置: 首页>>代码示例>>Python>>正文


Python CityLocation.get_cities_by方法代码示例

本文整理汇总了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)))
开发者ID:romaia,项目名称:stoq,代码行数:37,代码来源:test_address.py

示例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))
开发者ID:hackedbellini,项目名称:stoq,代码行数:16,代码来源:addressslave.py


注:本文中的stoqlib.domain.address.CityLocation.get_cities_by方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。