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


Python BlueShardFactory.build_batch方法代码示例

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


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

示例1: test_get_blue

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

示例2: test_blue_miss

# 需要导入模块: from ichnaea.tests.factories import BlueShardFactory [as 别名]
# 或者: from ichnaea.tests.factories.BlueShardFactory import build_batch [as 别名]
    def test_blue_miss(self):
        blues = BlueShardFactory.build_batch(2, samples=10)
        self.session.flush()

        query = self.model_query(blues=blues)
        results = self.source.search(query)
        self.check_model_results(results, None)
开发者ID:amolk4games,项目名称:ichnaea,代码行数:9,代码来源:test_internal.py

示例3: add_reports

# 需要导入模块: from ichnaea.tests.factories import BlueShardFactory [as 别名]
# 或者: from ichnaea.tests.factories.BlueShardFactory import build_batch [as 别名]
    def add_reports(self, num=1, blue_factor=0, cell_factor=1, wifi_factor=2,
                    api_key='test', nickname=None,
                    blue_key=None, cell_mcc=None, wifi_key=None,
                    lat=None, lon=None):
        reports = []
        for i in range(num):
            pos = CellShardFactory.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 = BlueShardFactory.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 = CellShardFactory.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)

        items = [{'api_key': api_key,
                  'nickname': nickname,
                  'report': rep} for rep in reports]

        self.incoming_queue.enqueue(items)
        update_incoming.delay().get()
        return reports
开发者ID:mate1983,项目名称:ichnaea,代码行数:62,代码来源:base.py

示例4: test_get_blue

# 需要导入模块: from ichnaea.tests.factories import BlueShardFactory [as 别名]
# 或者: from ichnaea.tests.factories.BlueShardFactory import build_batch [as 别名]
 def test_get_blue(self, cache, stats):
     blues = BlueShardFactory.build_batch(2)
     query = self._query(blue=self.blue_model_query(blues))
     assert cache.get(query) is None
     stats.check(counter=[
         ('locate.fallback.cache', 1, 1,
             [self.fallback_tag, 'status:miss']),
     ])
开发者ID:crankycoder,项目名称:ichnaea,代码行数:10,代码来源:test_fallback.py

示例5: test_blue_miss

# 需要导入模块: from ichnaea.tests.factories import BlueShardFactory [as 别名]
# 或者: from ichnaea.tests.factories.BlueShardFactory import build_batch [as 别名]
    def test_blue_miss(self, geoip_db, http_session,
                       session, source, stats):
        blues = BlueShardFactory.build_batch(2, samples=10)
        session.flush()

        query = self.model_query(
            geoip_db, http_session, session, stats,
            blues=blues)
        results = source.search(query)
        self.check_model_results(results, None)
开发者ID:crankycoder,项目名称:ichnaea,代码行数:12,代码来源:test_internal.py

示例6: test_set_blue

# 需要导入模块: from ichnaea.tests.factories import BlueShardFactory [as 别名]
# 或者: from ichnaea.tests.factories.BlueShardFactory import build_batch [as 别名]
 def test_set_blue(self):
     blues = BlueShardFactory.build_batch(2)
     blue = blues[0]
     query = Query(blue=self.blue_model_query(blues))
     result = ExternalResult(blue.lat, blue.lon, blue.radius, None)
     self.cache.set(query, result)
     self.assertEqual(self.cache.get(query), result)
     self.check_stats(counter=[
         ('locate.fallback.cache', 1, 1, ['status:hit']),
     ])
开发者ID:mate1983,项目名称:ichnaea,代码行数:12,代码来源:test_fallback.py

示例7: test_set_blue

# 需要导入模块: from ichnaea.tests.factories import BlueShardFactory [as 别名]
# 或者: from ichnaea.tests.factories.BlueShardFactory import build_batch [as 别名]
 def test_set_blue(self, cache, stats):
     blues = BlueShardFactory.build_batch(2)
     blue = blues[0]
     query = self._query(blue=self.blue_model_query(blues))
     result = ExternalResult(blue.lat, blue.lon, blue.radius, None)
     cache.set(query, result)
     assert cache.get(query) == result
     stats.check(counter=[
         ('locate.fallback.cache', 1, 1,
             [self.fallback_tag, 'status:hit']),
     ])
开发者ID:crankycoder,项目名称:ichnaea,代码行数:13,代码来源:test_fallback.py

示例8: test_blue_better

# 需要导入模块: from ichnaea.tests.factories import BlueShardFactory [as 别名]
# 或者: from ichnaea.tests.factories.BlueShardFactory import build_batch [as 别名]
 def test_blue_better(self):
     blues = BlueShardFactory.build_batch(2)
     query = Query(blue=[
         {'mac': blues[0].mac, 'signal': -90, 'name': 'my-beacon'},
         {'mac': blues[0].mac, 'signal': -82},
         {'mac': blues[0].mac, 'signal': -85},
         {'mac': blues[1].mac, 'signal': -70},
     ])
     self.assertEqual(len(query.blue), 2)
     self.assertEqual(
         set([blue.signal for blue in query.blue]), set([-70, -82]))
开发者ID:amolk4games,项目名称:ichnaea,代码行数:13,代码来源:test_query.py

示例9: test_many

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

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

示例10: test_blue_better

# 需要导入模块: from ichnaea.tests.factories import BlueShardFactory [as 别名]
# 或者: from ichnaea.tests.factories.BlueShardFactory import build_batch [as 别名]
 def test_blue_better(self):
     blues = BlueShardFactory.build_batch(2)
     query = Query(blue=[
         {'macAddress': blues[0].mac, 'signalStrength': -90,
          'name': 'my-beacon'},
         {'macAddress': blues[0].mac, 'signalStrength': -82},
         {'macAddress': blues[0].mac, 'signalStrength': -85},
         {'macAddress': blues[1].mac, 'signalStrength': -70},
     ])
     assert len(query.blue) == 2
     assert (set([blue.signalStrength for blue in query.blue]) ==
             set([-70, -82]))
开发者ID:crankycoder,项目名称:ichnaea,代码行数:14,代码来源:test_query.py

示例11: test_blue

# 需要导入模块: from ichnaea.tests.factories import BlueShardFactory [as 别名]
# 或者: from ichnaea.tests.factories.BlueShardFactory import build_batch [as 别名]
    def test_blue(self):
        blues = BlueShardFactory.build_batch(2)
        macs = [blue.mac for blue in blues]
        query = Query(blue=self.blue_model_query(blues))

        self.assertEqual(len(query.blue), 2)
        self.assertEqual(query.expected_accuracy, DataAccuracy.high)

        for blue in query.blue:
            self.assertEqual(blue.age, 10)
            self.assertEqual(blue.signal, -85)
            self.assertTrue(blue.mac in macs)
开发者ID:amolk4games,项目名称:ichnaea,代码行数:14,代码来源:test_query.py

示例12: test_blue

# 需要导入模块: from ichnaea.tests.factories import BlueShardFactory [as 别名]
# 或者: from ichnaea.tests.factories.BlueShardFactory import build_batch [as 别名]
    def test_blue(self):
        blues = BlueShardFactory.build_batch(2)
        macs = [blue.mac for blue in blues]
        query = Query(blue=self.blue_model_query(blues))

        assert len(query.blue) == 2
        assert query.expected_accuracy is DataAccuracy.high

        for blue in query.blue:
            assert blue.age == 10
            assert blue.signalStrength == -85
            assert blue.macAddress in macs
开发者ID:amjadm61,项目名称:ichnaea,代码行数:14,代码来源:test_query.py

示例13: test_one

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

        self._make_query(
            geoip_db, stats,
            blue=blues, cell=cells, wifi=wifis, ip=self.london_ip)
        stats.check(total=1, counter=[
            ('locate.query',
                ['key:test', 'region:GB',
                 'blue:one', 'cell:one', 'wifi:one']),
        ])
开发者ID:crankycoder,项目名称:ichnaea,代码行数:15,代码来源:test_query.py

示例14: test_blue

# 需要导入模块: from ichnaea.tests.factories import BlueShardFactory [as 别名]
# 或者: from ichnaea.tests.factories.BlueShardFactory import build_batch [as 别名]
 def test_blue(self):
     blues = BlueShardFactory.build_batch(2)
     query = Query(blue=[
         {'mac': blue.mac, 'signal': -90, 'name': 'my'} for blue in blues])
     data = self.schema.deserialize(query.internal_query())
     self.assertEqual(data, {
         'bluetoothBeacons': [{
             'macAddress': blues[0].mac,
             'signalStrength': -90,
             'name': 'my',
         }, {
             'macAddress': blues[1].mac,
             'signalStrength': -90,
             'name': 'my',
         }],
         'fallbacks': {'lacf': True},
     })
开发者ID:mate1983,项目名称:ichnaea,代码行数:19,代码来源:test_fallback.py

示例15: test_get_mixed

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

        query = Query(cell=self.cell_model_query(cells),
                      wifi=self.wifi_model_query(wifis))
        self.assertEqual(self.cache.get(query), None)

        query = Query(blue=self.blue_model_query(blues),
                      cell=self.cell_model_query(cells))
        self.assertEqual(self.cache.get(query), None)

        query = Query(blue=self.blue_model_query(blues),
                      wifi=self.wifi_model_query(wifis))
        self.assertEqual(self.cache.get(query), None)

        self.check_stats(counter=[
            ('locate.fallback.cache', 3, 1, ['status:bypassed']),
        ])
开发者ID:mate1983,项目名称:ichnaea,代码行数:22,代码来源:test_fallback.py


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