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


Python CellFactory.build_batch方法代码示例

本文整理汇总了Python中ichnaea.tests.factories.CellFactory.build_batch方法的典型用法代码示例。如果您正苦于以下问题:Python CellFactory.build_batch方法的具体用法?Python CellFactory.build_batch怎么用?Python CellFactory.build_batch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ichnaea.tests.factories.CellFactory的用法示例。


在下文中一共展示了CellFactory.build_batch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_cell_multi

# 需要导入模块: from ichnaea.tests.factories import CellFactory [as 别名]
# 或者: from ichnaea.tests.factories.CellFactory import build_batch [as 别名]
 def test_get_cell_multi(self):
     cells = CellFactory.build_batch(2)
     query = Query(cell=self.cell_model_query(cells))
     self.assertEqual(self.cache.get(query), None)
     self.check_stats(counter=[
         ('locate.fallback.cache', 1, 1, ['status:bypassed']),
     ])
开发者ID:voolitels,项目名称:ichnaea,代码行数:9,代码来源:test_fallback.py

示例2: test_no_call_made_when_not_allowed_for_apikey

# 需要导入模块: from ichnaea.tests.factories import CellFactory [as 别名]
# 或者: from ichnaea.tests.factories.CellFactory import build_batch [as 别名]
    def test_no_call_made_when_not_allowed_for_apikey(self):
        cells = CellFactory.build_batch(2)
        wifis = WifiFactory.build_batch(2)
        self.provider.api_key.allow_fallback = False

        query = self.model_query(cells=cells, wifis=wifis)
        self.check_should_locate(query, False)
开发者ID:SOFTowaha,项目名称:ichnaea,代码行数:9,代码来源:test_fallback.py

示例3: test_database_error

# 需要导入模块: from ichnaea.tests.factories import CellFactory [as 别名]
# 或者: from ichnaea.tests.factories.CellFactory import build_batch [as 别名]
    def test_database_error(self, db_errors=0):
        cells = CellFactory.build_batch(2)
        wifis = WifiShardFactory.build_batch(2)

        for model in (Cell, CellArea, CellOCID, CellAreaOCID):
            self.session.execute(text('drop table %s;' % model.__tablename__))
        for name in set([wifi.__tablename__ for wifi in wifis]):
            self.session.execute(text('drop table %s;' % name))

        query = self.model_query(cells=cells, wifis=wifis)
        res = self._call(body=query, ip=self.test_ip)
        self.check_response(res, 'ok')
        self.check_stats(counter=[
            ('request', [self.metric_path, 'method:post', 'status:200']),
        ], timer=[
            ('request', [self.metric_path, 'method:post']),
        ])
        if self.apikey_metrics:
            self.check_stats(counter=[
                (self.metric_type + '.result',
                    ['key:test', 'region:GB', 'fallback_allowed:false',
                     'accuracy:high', 'status:miss']),
            ])

        self.check_raven([('ProgrammingError', db_errors)])
开发者ID:voolitels,项目名称:ichnaea,代码行数:27,代码来源:base.py

示例4: test_database_error

# 需要导入模块: from ichnaea.tests.factories import CellFactory [as 别名]
# 或者: from ichnaea.tests.factories.CellFactory import build_batch [as 别名]
    def test_database_error(self, db_errors=0):
        for tablename in ('cell', 'cell_area',
                          'ocid_cell', 'ocid_cell_area'):
            self.session.execute(text('drop table %s;' % tablename))
        for i in range(16):
            self.session.execute(text(
                'drop table wifi_shard_%s;' % hex(i)[2:]))

        cells = CellFactory.build_batch(2)
        wifis = WifiShardFactory.build_batch(2)

        query = self.model_query(cells=cells, wifis=wifis)
        res = self._call(body=query, ip=self.test_ip)
        self.check_response(res, 'ok')
        self.check_stats(counter=[
            ('request', [self.metric_path, 'method:post', 'status:200']),
        ], timer=[
            ('request', [self.metric_path, 'method:post']),
        ])
        if self.apikey_metrics:
            self.check_stats(counter=[
                (self.metric_type + '.result',
                    ['key:test', 'country:GB',
                     'accuracy:high', 'status:miss']),
            ])

        self.check_raven([('ProgrammingError', db_errors)])
开发者ID:therewillbecode,项目名称:ichnaea,代码行数:29,代码来源:base.py

示例5: setUp

# 需要导入模块: from ichnaea.tests.factories import CellFactory [as 别名]
# 或者: from ichnaea.tests.factories.CellFactory import build_batch [as 别名]
    def setUp(self):
        super(TestFallbackProvider, self).setUp()

        self.provider.api_key.allow_fallback = True

        self.response_location = {
            'location': {
                'lat': 51.5366,
                'lng': 0.03989,
            },
            'accuracy': 1500,
            'fallback': 'lacf',
        }

        self.cells = []
        for cell in CellFactory.build_batch(2):
            self.cells.append({
                'radio': cell.radio,
                'mcc': cell.mcc,
                'mnc': cell.mnc,
                'lac': cell.lac,
                'cid': cell.cid,
                'signal': -70,
            })
        self.cells[0]['ta'] = 1

        self.wifis = []
        for wifi in WifiFactory.build_batch(2):
            self.wifis.append({
                'key': wifi.key,
                'signal': -77,
            })
        self.wifis[0]['channel'] = 6
        self.wifis[0]['frequency'] = 2437
        self.wifis[0]['snr'] = 13
开发者ID:JaredKerim-Mozilla,项目名称:ichnaea,代码行数:37,代码来源:test_provider.py

示例6: test_medium_hit

# 需要导入模块: from ichnaea.tests.factories import CellFactory [as 别名]
# 或者: from ichnaea.tests.factories.CellFactory import build_batch [as 别名]
 def test_medium_hit(self):
     cells = CellFactory.build_batch(1)
     self._make_query(self._make_result(accuracy=30000.0), cell=cells)
     self.check_stats(counter=[
         ('locate.result',
             ['key:key', 'country:none', 'accuracy:medium', 'status:hit']),
     ])
开发者ID:therewillbecode,项目名称:ichnaea,代码行数:9,代码来源:test_query.py

示例7: test_api_key_disallows

# 需要导入模块: from ichnaea.tests.factories import CellFactory [as 别名]
# 或者: from ichnaea.tests.factories.CellFactory import build_batch [as 别名]
    def test_api_key_disallows(self):
        api_key = ApiKeyFactory.build(allow_fallback=False)
        cells = CellFactory.build_batch(2)
        wifis = WifiShardFactory.build_batch(2)

        query = self.model_query(cells=cells, wifis=wifis, api_key=api_key)
        self.check_should_search(query, False)
开发者ID:voolitels,项目名称:ichnaea,代码行数:9,代码来源:test_fallback.py

示例8: test_fallback_used_when_geoip_also_present

# 需要导入模块: from ichnaea.tests.factories import CellFactory [as 别名]
# 或者: from ichnaea.tests.factories.CellFactory import build_batch [as 别名]
    def test_fallback_used_when_geoip_also_present(self):
        cells = CellFactory.build_batch(2, radio=Radio.wcdma)
        wifis = WifiFactory.build_batch(3)
        api_key = ApiKey.getkey(self.session, 'test')
        api_key.allow_fallback = True
        self.session.flush()

        with requests_mock.Mocker() as mock:
            response_location = {
                'location': {
                    'lat': 1.0,
                    'lng': 1.0,
                },
                'accuracy': 100,
            }
            mock.register_uri(
                'POST', requests_mock.ANY, json=response_location)

            query = self.model_query(cells=cells, wifis=wifis)
            res = self._call(body=query, ip=self.test_ip)

            send_json = mock.request_history[0].json()
            self.assertEqual(len(send_json['cellTowers']), 2)
            self.assertEqual(len(send_json['wifiAccessPoints']), 3)

        self.check_model_response(res, None, lat=1.0, lon=1.0, accuracy=100)

        self.check_stats(
            timer=[self.metric_url],
            counter=[self.metric + '.api_key.test',
                     self.metric + '.fallback_hit',
                     self.metric_url + '.200',
                     self.metric + '.api_log.test.fallback_hit'],
        )
开发者ID:SOFTowaha,项目名称:ichnaea,代码行数:36,代码来源:base.py

示例9: test_medium_miss_low

# 需要导入模块: from ichnaea.tests.factories import CellFactory [as 别名]
# 或者: from ichnaea.tests.factories.CellFactory import build_batch [as 别名]
 def test_medium_miss_low(self):
     cells = CellFactory.build_batch(1)
     self._make_query(self._make_result(accuracy=50000.1), cell=cells)
     self.check_stats(counter=[
         ('locate.result',
             ['key:key', 'region:none', 'fallback_allowed:false',
              'accuracy:medium', 'status:miss']),
     ])
开发者ID:voolitels,项目名称:ichnaea,代码行数:10,代码来源:test_query.py

示例10: test_mixed_cell_wifi

# 需要导入模块: from ichnaea.tests.factories import CellFactory [as 别名]
# 或者: from ichnaea.tests.factories.CellFactory import build_batch [as 别名]
    def test_mixed_cell_wifi(self):
        cells = CellFactory.build_batch(1)
        wifis = WifiShardFactory.build_batch(2)

        query = Query(
            cell=self.cell_model_query(cells),
            wifi=self.wifi_model_query(wifis))
        self.assertEqual(query.expected_accuracy, DataAccuracy.high)
开发者ID:voolitels,项目名称:ichnaea,代码行数:10,代码来源:test_query.py

示例11: test_mixed_hit

# 需要导入模块: from ichnaea.tests.factories import CellFactory [as 别名]
# 或者: from ichnaea.tests.factories.CellFactory import build_batch [as 别名]
 def test_mixed_hit(self):
     cells = CellFactory.build_batch(2)
     self._make_query(
         self._make_result(accuracy=500.0), cell=cells, ip=self.london_ip)
     self.check_stats(counter=[
         ('locate.result',
             ['key:key', 'country:GB', 'accuracy:medium', 'status:hit']),
     ])
开发者ID:therewillbecode,项目名称:ichnaea,代码行数:10,代码来源:test_query.py

示例12: test_one

# 需要导入模块: from ichnaea.tests.factories import CellFactory [as 别名]
# 或者: from ichnaea.tests.factories.CellFactory import build_batch [as 别名]
    def test_one(self):
        cells = CellFactory.build_batch(1)
        wifis = WifiShardFactory.build_batch(1)

        self._make_query(cell=cells, wifi=wifis, ip=self.london_ip)
        self.check_stats(total=1, counter=[
            ('locate.query',
                ['key:key', 'country:GB', 'cell:one', 'wifi:one']),
        ])
开发者ID:therewillbecode,项目名称:ichnaea,代码行数:11,代码来源:test_query.py

示例13: test_many

# 需要导入模块: from ichnaea.tests.factories import CellFactory [as 别名]
# 或者: from ichnaea.tests.factories.CellFactory import build_batch [as 别名]
    def test_many(self):
        cells = CellFactory.build_batch(2)
        wifis = WifiShardFactory.build_batch(3)

        self._make_query(cell=cells, wifi=wifis, ip=self.london_ip)
        self.check_stats(total=1, counter=[
            ('locate.query',
                ['key:key', 'region:GB', 'cell:many', 'wifi:many']),
        ])
开发者ID:voolitels,项目名称:ichnaea,代码行数:11,代码来源:test_query.py

示例14: add_reports

# 需要导入模块: from ichnaea.tests.factories import CellFactory [as 别名]
# 或者: from ichnaea.tests.factories.CellFactory import build_batch [as 别名]
    def add_reports(self, num=1, blue_factor=0, cell_factor=1, wifi_factor=2,
                    api_key='test', email=None, ip=None, nickname=None,
                    blue_key=None, cell_mcc=None, wifi_key=None,
                    lat=None, lon=None):
        reports = []
        for i in range(num):
            pos = CellFactory.build()
            report = {
                'timestamp': time.time() * 1000.0,
                'position': {},
                'bluetoothBeacons': [],
                'cellTowers': [],
                'wifiAccessPoints': [],
            }
            report['position']['latitude'] = lat or pos.lat
            report['position']['longitude'] = lon or pos.lon
            report['position']['accuracy'] = 17.0 + i

            blues = WifiShardFactory.build_batch(blue_factor,
                                                 lat=pos.lat, lon=pos.lon)
            for blue in blues:
                blue_data = {
                    'macAddress': blue_key or blue.mac,
                    'signalStrength': -100 + i,
                }
                report['bluetoothBeacons'].append(blue_data)

            cells = CellFactory.build_batch(cell_factor,
                                            lat=pos.lat, lon=pos.lon)
            for cell in cells:
                cell_data = {
                    'radioType': cell.radio.name,
                    'mobileCountryCode': cell_mcc or cell.mcc,
                    'mobileNetworkCode': cell.mnc,
                    'locationAreaCode': cell.lac,
                    'cellId': cell.cid,
                    'primaryScramblingCode': cell.psc,
                    'signalStrength': -110 + i,
                }
                report['cellTowers'].append(cell_data)

            wifis = WifiShardFactory.build_batch(wifi_factor,
                                                 lat=pos.lat, lon=pos.lon)
            for wifi in wifis:
                wifi_data = {
                    'macAddress': wifi_key or wifi.mac,
                    'signalStrength': -90 + i,
                    'ssid': 'my-wifi',
                }
                report['wifiAccessPoints'].append(wifi_data)

            reports.append(report)

        queue_reports.delay(reports=reports, api_key=api_key,
                            email=email, ip=ip, nickname=nickname).get()
        return reports
开发者ID:voolitels,项目名称:ichnaea,代码行数:58,代码来源:test_export.py

示例15: test_apikey_error

# 需要导入模块: from ichnaea.tests.factories import CellFactory [as 别名]
# 或者: from ichnaea.tests.factories.CellFactory import build_batch [as 别名]
    def test_apikey_error(self, db_errors=0):
        cells = CellFactory.build_batch(2)
        wifis = WifiShardFactory.build_batch(2)

        self.session.execute(text('drop table %s;' % ApiKey.__tablename__))

        query = self.model_query(cells=cells, wifis=wifis)
        res = self._call(body=query, ip=self.test_ip)
        self.check_response(res, 'ok')
        self.check_raven([('ProgrammingError', db_errors)])
开发者ID:voolitels,项目名称:ichnaea,代码行数:12,代码来源:base.py


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