本文整理汇总了Python中ichnaea.tests.factories.BlueShardFactory.build方法的典型用法代码示例。如果您正苦于以下问题:Python BlueShardFactory.build方法的具体用法?Python BlueShardFactory.build怎么用?Python BlueShardFactory.build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ichnaea.tests.factories.BlueShardFactory
的用法示例。
在下文中一共展示了BlueShardFactory.build方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_blue
# 需要导入模块: from ichnaea.tests.factories import BlueShardFactory [as 别名]
# 或者: from ichnaea.tests.factories.BlueShardFactory import build [as 别名]
def test_blue(self):
blue = BlueShardFactory.build()
self._post([{
'latitude': blue.lat,
'longitude': blue.lon,
'bluetoothBeacons': [{
'macAddress': blue.mac,
'age': 3,
'signalStrength': -90,
'name': 'my-beacon',
'xtra_field': 3,
}]},
])
self.assertEqual(self.queue.size(), 1)
item = self.queue.dequeue()[0]
self.assertEqual(item['api_key'], None)
report = item['report']
self.assertTrue('timestamp' in report)
position = report['position']
self.assertEqual(position['latitude'], blue.lat)
self.assertEqual(position['longitude'], blue.lon)
blues = item['report']['bluetoothBeacons']
self.assertEqual(len(blues), 1)
self.assertEqual(blues[0]['macAddress'], blue.mac)
self.assertEqual(blues[0]['age'], 3),
self.assertEqual(blues[0]['signalStrength'], -90),
self.assertEqual(blues[0]['name'], 'my-beacon'),
self.assertFalse('xtra_field' in blues[0])
示例2: test_blue
# 需要导入模块: from ichnaea.tests.factories import BlueShardFactory [as 别名]
# 或者: from ichnaea.tests.factories.BlueShardFactory import build [as 别名]
def test_blue(self, app, celery):
blue = BlueShardFactory.build()
res = self._post(app, [{
'lat': blue.lat,
'lon': blue.lon,
'source': '',
'blue': [{
'key': blue.mac,
'age': 3000,
'name': 'beacon',
'signal': -101,
}]},
])
assert res.body == b''
assert self.queue(celery).size() == 1
item = self.queue(celery).dequeue()[0]
assert item['api_key'] is None
report = item['report']
position = report['position']
assert position['latitude'] == blue.lat
assert position['longitude'] == blue.lon
assert 'source' not in position
blues = item['report']['bluetoothBeacons']
assert len(blues) == 1
assert blues[0]['macAddress'] == blue.mac
assert blues[0]['age'] == 3000
assert blues[0]['name'] == 'beacon'
assert blues[0]['signalStrength'] == -101
示例3: test_blue
# 需要导入模块: from ichnaea.tests.factories import BlueShardFactory [as 别名]
# 或者: from ichnaea.tests.factories.BlueShardFactory import build [as 别名]
def test_blue(self, app, celery):
blue = BlueShardFactory.build()
self._post(app, [{
'latitude': blue.lat,
'longitude': blue.lon,
'bluetoothBeacons': [{
'macAddress': blue.mac,
'age': 3,
'signalStrength': -90,
'name': 'my-beacon',
'xtra_field': 3,
}]},
])
assert self.queue(celery).size() == 1
item = self.queue(celery).dequeue()[0]
assert item['api_key'] is None
report = item['report']
assert 'timestamp' in report
position = report['position']
assert position['latitude'] == blue.lat
assert position['longitude'] == blue.lon
blues = item['report']['bluetoothBeacons']
assert len(blues) == 1
assert blues[0]['macAddress'] == blue.mac
assert blues[0]['age'] == 3
assert blues[0]['signalStrength'] == -90
assert blues[0]['name'] == 'my-beacon'
assert 'xtra_field' not in blues[0]
示例4: test_blue
# 需要导入模块: from ichnaea.tests.factories import BlueShardFactory [as 别名]
# 或者: from ichnaea.tests.factories.BlueShardFactory import build [as 别名]
def test_blue(self):
blue = BlueShardFactory.build()
res = self._post([{
'lat': blue.lat,
'lon': blue.lon,
'blue': [{
'key': blue.mac,
'age': 3000,
'name': 'beacon',
'signal': -101,
}]},
])
self.assertEqual(res.body, b'')
self.assertEqual(self.queue.size(), 1)
item = self.queue.dequeue()[0]
self.assertEqual(item['api_key'], None)
report = item['report']
position = report['position']
self.assertEqual(position['latitude'], blue.lat)
self.assertEqual(position['longitude'], blue.lon)
blues = item['report']['bluetoothBeacons']
self.assertEqual(len(blues), 1)
self.assertEqual(blues[0]['macAddress'], blue.mac)
self.assertEqual(blues[0]['age'], 3000),
self.assertEqual(blues[0]['name'], 'beacon'),
self.assertEqual(blues[0]['signalStrength'], -101),
示例5: test_blue_duplicates
# 需要导入模块: from ichnaea.tests.factories import BlueShardFactory [as 别名]
# 或者: from ichnaea.tests.factories.BlueShardFactory import build [as 别名]
def test_blue_duplicates(self):
blue = BlueShardFactory.build()
query = Query(blue=[
{'macAddress': blue.mac, 'signalStrength': -90},
{'macAddress': blue.mac, 'signalStrength': -82},
{'macAddress': blue.mac, 'signalStrength': -85},
])
assert len(query.blue) == 0
示例6: test_check_one_blue
# 需要导入模块: from ichnaea.tests.factories import BlueShardFactory [as 别名]
# 或者: from ichnaea.tests.factories.BlueShardFactory import build [as 别名]
def test_check_one_blue(self, geoip_db, http_session,
session, source, stats):
blue = BlueShardFactory.build()
query = self.model_query(
geoip_db, http_session, session, stats,
blues=[blue])
self.check_should_search(source, query, False)
示例7: test_blue_duplicates
# 需要导入模块: from ichnaea.tests.factories import BlueShardFactory [as 别名]
# 或者: from ichnaea.tests.factories.BlueShardFactory import build [as 别名]
def test_blue_duplicates(self):
blue = BlueShardFactory.build()
query = Query(blue=[
{'mac': blue.mac, 'signal': -90},
{'mac': blue.mac, 'signal': -82},
{'mac': blue.mac, 'signal': -85},
])
self.assertEqual(len(query.blue), 0)
示例8: test_blue
# 需要导入模块: from ichnaea.tests.factories import BlueShardFactory [as 别名]
# 或者: from ichnaea.tests.factories.BlueShardFactory import build [as 别名]
def test_blue(self):
now = util.utcnow()
region = GEOCODER.regions_for_mcc(235, metadata=True)[0]
blue1 = BlueShardFactory(samples=10)
blue2 = BlueShardFactory(samples=20)
blue3 = BlueShardFactory.build(region='DE', samples=100)
self.session.flush()
query = self.model_query(blues=[blue1, blue2, blue3])
results = self.source.search(query)
self.check_model_results(results, [region])
best_result = results.best()
self.assertEqual(best_result.region_code, region.code)
self.assertAlmostEqual(
best_result.score, blue1.score(now) + blue2.score(now), 4)
self.check_stats(counter=[
(self.api_type + '.source',
['key:test', 'region:none', 'source:internal',
'accuracy:low', 'status:hit']),
])
示例9: test_bluetooth
# 需要导入模块: from ichnaea.tests.factories import BlueShardFactory [as 别名]
# 或者: from ichnaea.tests.factories.BlueShardFactory import build [as 别名]
def test_bluetooth(self):
blue = BlueShardFactory.build()
self._post([{
'position': {
'latitude': blue.lat,
'longitude': blue.lon,
},
'bluetoothBeacons': [{
'macAddress': blue.mac,
'name': 'my-beacon',
'age': 3,
'signalStrength': -90,
'xtra_field': 4,
}, {
'name': 'beacon-2',
'signalStrength': -92,
}],
'wifiAccessPoints': [{
'signalStrength': -52,
}]},
])
self._assert_queue_size(1)
item = self.queue.dequeue(self.queue.queue_key())[0]
report = item['report']
self.assertTrue('timestamp' in report)
position = report['position']
self.assertEqual(position['latitude'], blue.lat)
self.assertEqual(position['longitude'], blue.lon)
blues = report['bluetoothBeacons']
self.assertEqual(len(blues), 1)
self.assertEqual(blues[0]['macAddress'], blue.mac)
self.assertEqual(blues[0]['age'], 3),
self.assertEqual(blues[0]['name'], 'my-beacon'),
self.assertEqual(blues[0]['signalStrength'], -90),
self.assertFalse('xtra_field' in blues[0])
wifis = report['wifiAccessPoints']
self.assertEqual(len(wifis), 0)
示例10: test_bluetooth
# 需要导入模块: from ichnaea.tests.factories import BlueShardFactory [as 别名]
# 或者: from ichnaea.tests.factories.BlueShardFactory import build [as 别名]
def test_bluetooth(self, app, celery):
blue = BlueShardFactory.build()
self._post(app, [{
'position': {
'latitude': blue.lat,
'longitude': blue.lon,
},
'bluetoothBeacons': [{
'macAddress': blue.mac,
'name': 'my-beacon',
'age': 3,
'signalStrength': -90,
'xtra_field': 4,
}, {
'name': 'beacon-2',
'signalStrength': -92,
}],
'wifiAccessPoints': [{
'signalStrength': -52,
}]},
])
assert self.queue(celery).size() == 1
item = self.queue(celery).dequeue()[0]
report = item['report']
assert 'timestamp' in report
position = report['position']
assert position['latitude'] == blue.lat
assert position['longitude'] == blue.lon
blues = report['bluetoothBeacons']
assert len(blues) == 1
assert blues[0]['macAddress'] == blue.mac
assert blues[0]['age'] == 3
assert blues[0]['name'] == 'my-beacon'
assert blues[0]['signalStrength'] == -90
assert 'xtra_field' not in blues[0]
wifis = report['wifiAccessPoints']
assert len(wifis) == 0
示例11: test_blue
# 需要导入模块: from ichnaea.tests.factories import BlueShardFactory [as 别名]
# 或者: from ichnaea.tests.factories.BlueShardFactory import build [as 别名]
def test_blue(self, geoip_db, http_session,
session, source, stats):
now = util.utcnow()
region = GEOCODER.regions_for_mcc(235, metadata=True)[0]
blue1 = BlueShardFactory(samples=10)
blue2 = BlueShardFactory(samples=20)
blue3 = BlueShardFactory.build(region='DE', samples=100)
session.flush()
query = self.model_query(
geoip_db, http_session, session, stats,
blues=[blue1, blue2, blue3])
results = source.search(query)
self.check_model_results(results, [region])
best_result = results.best()
assert best_result.region_code == region.code
assert (best_result.score ==
station_score(blue1, now) + station_score(blue2, now))
stats.check(counter=[
(self.api_type + '.source',
['key:test', 'region:none', 'source:internal',
'accuracy:low', 'status:hit']),
])
示例12: test_blue_single
# 需要导入模块: from ichnaea.tests.factories import BlueShardFactory [as 别名]
# 或者: from ichnaea.tests.factories.BlueShardFactory import build [as 别名]
def test_blue_single(self):
blue = BlueShardFactory.build()
blue_query = {'mac': blue.mac}
query = Query(blue=[blue_query])
self.assertEqual(len(query.blue), 0)
示例13: test_empty_blue_entry
# 需要导入模块: from ichnaea.tests.factories import BlueShardFactory [as 别名]
# 或者: from ichnaea.tests.factories.BlueShardFactory import build [as 别名]
def test_empty_blue_entry(self):
blue = BlueShardFactory.build()
data = SUBMIT_V0_SCHEMA.deserialize({'items': [
{'lat': blue.lat, 'lon': blue.lon, 'blue': [{}]},
]})
assert data == {'items': []}
示例14: test_blue_malformed
# 需要导入模块: from ichnaea.tests.factories import BlueShardFactory [as 别名]
# 或者: from ichnaea.tests.factories.BlueShardFactory import build [as 别名]
def test_blue_malformed(self):
blue = BlueShardFactory.build()
blue_query = {'macAddress': blue.mac}
query = Query(blue=[blue_query, {'macAddress': 'foo'}])
assert len(query.blue) == 0
示例15: test_empty_blue_entry
# 需要导入模块: from ichnaea.tests.factories import BlueShardFactory [as 别名]
# 或者: from ichnaea.tests.factories.BlueShardFactory import build [as 别名]
def test_empty_blue_entry(self):
blue = BlueShardFactory.build()
data = self.schema.deserialize({'items': [
{'lat': blue.lat, 'lon': blue.lon, 'blue': [{}]},
]})
self.assertEqual(data, {'items': []})