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)
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, [])
def test_scan_areas_remove(self): session = self.session redis_client = self.redis_client # create an orphaned lac entry area = CellAreaFactory() session.flush() enqueue_areas(session, redis_client, [area.hashkey()], UPDATE_KEY['cell_lac']) # after scanning the orphaned record gets removed self.assertEqual(scan_areas.delay().get(), 1) areas = session.query(CellArea).all() self.assertEqual(areas, [])
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, [])
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)
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)