本文整理汇总了Python中ichnaea.tests.factories.CellAreaFactory类的典型用法代码示例。如果您正苦于以下问题:Python CellAreaFactory类的具体用法?Python CellAreaFactory怎么用?Python CellAreaFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CellAreaFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update
def test_update(self, celery, session):
area = CellAreaFactory(radio=Radio.gsm, num_cells=1)
area.region = None
BlueShardFactory.create_batch(2, region='CA')
BlueShardFactory.create_batch(3, region='GB')
CellAreaFactory(radio=Radio.gsm, region='DE', num_cells=1)
CellAreaFactory(radio=Radio.gsm, region='DE', num_cells=2)
CellAreaFactory(radio=Radio.gsm, region='CA', num_cells=2)
CellAreaFactory(radio=Radio.wcdma, region='DE', num_cells=3)
CellAreaFactory(radio=Radio.lte, region='CA', num_cells=4)
WifiShardFactory.create_batch(5, region='DE')
WifiShardFactory.create_batch(6, region='US')
wifi = WifiShardFactory()
wifi.region = None
session.add(RegionStat(region='US', blue=1, wifi=2))
session.add(RegionStat(region='TW', wifi=1))
session.flush()
update_statregion.delay().get()
stats = session.query(RegionStat).all()
assert len(stats) == 4
for stat in stats:
values = (stat.gsm, stat.wcdma, stat.lte, stat.blue, stat.wifi)
if stat.region == 'DE':
assert values == (3, 3, 0, 0, 5)
elif stat.region == 'CA':
assert values == (2, 0, 4, 2, 0)
elif stat.region == 'GB':
assert values == (0, 0, 0, 3, 0)
elif stat.region == 'US':
assert values == (0, 0, 0, 0, 6)
示例2: test_remove
def test_remove(self):
area = CellAreaFactory()
self.session.flush()
self.area_queue.enqueue([area.hashkey()])
self.assertEqual(scan_areas.delay().get(), 1)
self.assertEqual(self.session.query(CellArea).count(), 0)
示例3: test_update
def test_update(self):
area = CellAreaFactory(radio=Radio.gsm, num_cells=1)
area.region = None
CellAreaFactory(radio=Radio.gsm, region='DE', num_cells=1)
CellAreaFactory(radio=Radio.gsm, region='DE', num_cells=2)
CellAreaFactory(radio=Radio.gsm, region='CA', num_cells=2)
CellAreaFactory(radio=Radio.wcdma, region='DE', num_cells=3)
CellAreaFactory(radio=Radio.lte, region='CA', num_cells=4)
WifiShardFactory.create_batch(5, region='DE')
WifiShardFactory.create_batch(6, region='US')
wifi = WifiShardFactory()
wifi.region = None
self.session.add(RegionStat(region='US', wifi=2))
self.session.add(RegionStat(region='TW', wifi=1))
self.session.flush()
update_statregion.delay().get()
stats = self.session.query(RegionStat).all()
self.assertEqual(len(stats), 3)
for stat in stats:
values = (stat.gsm, stat.wcdma, stat.lte, stat.wifi)
if stat.region == 'DE':
self.assertEqual(values, (3, 3, 0, 5))
elif stat.region == 'CA':
self.assertEqual(values, (2, 0, 4, 0))
elif stat.region == 'US':
self.assertEqual(values, (0, 0, 0, 6))
示例4: test_scan_areas_remove
def test_scan_areas_remove(self):
# create an orphaned lac entry
area = CellAreaFactory()
self.session.flush()
self.area_queue.enqueue([area.hashkey()])
# after scanning the orphaned record gets removed
self.assertEqual(scan_areas.delay().get(), 1)
areas = self.session.query(CellArea).all()
self.assertEqual(areas, [])
示例5: test_smallest_area
def test_smallest_area(self):
now = util.utcnow()
area = CellAreaFactory(radius=25000, num_cells=8)
area2 = CellAreaFactory(radius=30000, lat=area.lat + 0.2, num_cells=6)
self.session.flush()
query = self.model_query(cells=[area, area2])
results = self.source.search(query)
self.check_model_results(results, [area])
self.assertAlmostEqual(results.best().score, area.score(now), 4)
示例6: test_multiple_mcc
def test_multiple_mcc(self):
now = util.utcnow()
region = GEOCODER.regions_for_mcc(235, metadata=True)[0]
cell = CellAreaFactory(mcc=234, num_cells=6)
cell2 = CellAreaFactory(mcc=235, num_cells=8)
self.session.flush()
query = self.model_query(cells=[cell, cell2])
results = self.source.search(query)
self.assertTrue(len(results) > 2)
best_result = results.best(query.expected_accuracy)
self.assertEqual(best_result.region_code, region.code)
self.assertAlmostEqual(best_result.score, 1.25 + cell.score(now), 4)
示例7: test_smallest_area
def test_smallest_area(self, geoip_db, http_session,
session, source, stats):
now = util.utcnow()
area = CellAreaFactory(radius=25000, num_cells=8)
area2 = CellAreaFactory(radius=30000, lat=area.lat + 0.2, num_cells=6)
session.flush()
query = self.model_query(
geoip_db, http_session, session, stats,
cells=[area, area2])
results = source.search(query)
self.check_model_results(results, [area])
assert results.best().score == area.score(now)
示例8: test_scan_areas_remove
def test_scan_areas_remove(self):
session = self.session
redis_client = self.redis_client
# create an orphaned lac entry
area = CellAreaFactory()
session.flush()
redis_key = self.celery_app.data_queues['cell_area_update']
enqueue_areas(session, redis_client,
[area.hashkey()], redis_key)
# after scanning the orphaned record gets removed
self.assertEqual(scan_areas.delay().get(), 1)
areas = session.query(CellArea).all()
self.assertEqual(areas, [])
示例9: test_update
def test_update(self):
area = CellAreaFactory(num_cells=2, range=500, avg_cell_range=100)
area_key = area.hashkey()
cell = CellFactory(
lat=area.lat, lon=area.lon, range=200, **area_key.__dict__)
self.session.commit()
self.area_queue.enqueue([area_key])
self.assertEqual(scan_areas.delay().get(), 1)
area = self.session.query(CellArea).one()
self.assertAlmostEqual(area.lat, cell.lat)
self.assertAlmostEqual(area.lon, cell.lon)
self.assertEqual(area.range, 0)
self.assertEqual(area.num_cells, 1)
self.assertEqual(area.avg_cell_range, 200)
示例10: test_cell_area_no_fallback
def test_cell_area_no_fallback(self):
cell = CellAreaFactory.build()
cell_query = self.cell_model_query([cell])
query = Query(cell=cell_query, fallback={'lacf': False})
self.assertEqual(len(query.cell), 0)
self.assertEqual(len(query.cell_area), 0)
self.assertEqual(query.expected_accuracy, DataAccuracy.none)
示例11: test_cell_area
def test_cell_area(self):
cell = CellAreaFactory.build()
cell_query = self.cell_model_query([cell])
query = Query(cell=cell_query)
self.assertEqual(len(query.cell), 0)
self.assertEqual(len(query.cell_area), 1)
self.assertEqual(query.expected_accuracy, DataAccuracy.low)
示例12: test_cell_area
def test_cell_area(self):
cell = CellAreaFactory.build()
cell_query = self.cell_model_query([cell])
query = Query(cell=cell_query)
assert len(query.cell) == 0
assert len(query.cell_area) == 1
assert query.expected_accuracy is DataAccuracy.low
示例13: test_cell_area_no_fallback
def test_cell_area_no_fallback(self):
cell = CellAreaFactory.build()
cell_query = self.cell_model_query([cell])
query = Query(cell=cell_query, fallback={'lacf': False})
assert len(query.cell) == 0
assert len(query.cell_area) == 0
assert query.expected_accuracy is DataAccuracy.none
示例14: test_update_incomplete_cell
def test_update_incomplete_cell(self):
area = CellAreaFactory(range=500)
area_key = area.hashkey()
cell = CellFactory(
lat=area.lat + 0.0002, lon=area.lon, **area_key.__dict__)
CellFactory(lat=None, lon=None, **area_key.__dict__)
CellFactory(lat=area.lat, lon=area.lon,
max_lat=None, min_lon=None, **area_key.__dict__)
self.session.commit()
self.area_queue.enqueue([area_key])
self.assertEqual(scan_areas.delay().get(), 1)
area = self.session.query(CellArea).one()
self.assertAlmostEqual(area.lat, cell.lat - 0.0001)
self.assertAlmostEqual(area.lon, cell.lon)
self.assertEqual(area.num_cells, 2)
示例15: test_invalid_mcc
def test_invalid_mcc(self, geoip_db, http_session,
session, source, stats):
area = CellAreaFactory.build(mcc=235, num_cells=10)
area.mcc = 999
query = self.model_query(
geoip_db, http_session, session, stats,
cells=[area])
results = source.search(query)
self.check_model_results(results, None)