本文整理汇总了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']),
])
示例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)
示例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
示例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']),
])
示例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)
示例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']),
])
示例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']),
])
示例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]))
示例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']),
])
示例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]))
示例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)
示例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
示例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']),
])
示例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},
})
示例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']),
])