def import_file(path='tests/custom_ddb.txt'): """Import registered devices from a local file.""" # (flushes previously manually imported entries) print("Import registered devices from '{}'...".format(path)) counter = update_devices(session, AddressOrigin.user_defined, get_ddb(path)) print("Imported %i devices." % counter)
def test_get_trackable(self): devices = get_ddb('tests/custom_ddb.txt') trackable = get_trackable(devices) self.assertEqual(len(trackable), 4) self.assertIn('FLRDD4711', trackable) self.assertIn('FLRDD0815', trackable) self.assertIn('OGNDEADBE', trackable) self.assertIn('ICA999999', trackable)
def update_device_infos(session, address_origin, csvfile=None): device_infos = get_ddb(csvfile=csvfile, address_origin=address_origin) session.query(DeviceInfo) \ .filter(DeviceInfo.address_origin == address_origin) \ .delete() session.bulk_save_objects(device_infos) session.commit() return len(device_infos)
def test_get_ddb_from_file(self): devices = get_ddb('tests/custom_ddb.txt') self.assertEqual(len(devices), 6) device = devices[0] self.assertEqual(device.address, 'DD4711') self.assertEqual(device.aircraft, 'HK36 TTC') self.assertEqual(device.registration, 'D-EULE') self.assertEqual(device.competition, 'CU') self.assertTrue(device.tracked) self.assertTrue(device.identified) self.assertEqual(device.aircraft_type, AircraftType.glider_or_motor_glider)
def test_get_ddb_from_file(self): devices = get_ddb('tests/custom_ddb.txt') self.assertEqual(len(devices), 6) device = devices[0] self.assertEqual(device.address, 'DD4711') self.assertEqual(device.aircraft, 'HK36 TTC') self.assertEqual(device.registration, 'D-EULE') self.assertEqual(device.competition, 'CU') self.assertTrue(device.tracked) self.assertTrue(device.identified) self.assertEqual(device.address_origin, AddressOrigin.user_defined)
def update_ddb_from_file(): logger.info("Import ddb data from file.") app.session.query(Device) \ .filter(AddressOrigin(Device.address_origin) is AddressOrigin.userdefined) \ .delete() devices = get_ddb('ogn/custom_ddb.txt') logger.debug("New Devices: %s" % str(devices)) app.session.bulk_save_objects(devices) app.session.commit() return len(devices)
def update_ddb_from_ogn(): logger.info("Update ddb data from ogn.") app.session.query(Device) \ .filter(AddressOrigin(Device.address_origin) is AddressOrigin.ogn_ddb) \ .delete() devices = get_ddb() logger.debug("New Devices: %s" % str(devices)) app.session.bulk_save_objects(devices) app.session.commit() return len(devices)
def test_get_devices(self): devices = get_ddb() self.assertGreater(len(devices), 1000)
def import_file(path='tests/custom_ddb.txt'): """Import registered devices from a local file.""" logger.info("Import registered devices from '{}'...".format(path)) counter = update_devices(app.session, AddressOrigin.user_defined, get_ddb(path)) logger.info("Imported {} devices.".format(counter))
def import_ddb(): """Import registered devices from the DDB.""" logger.info("Import registered devices fom the DDB...") counter = update_devices(app.session, AddressOrigin.ogn_ddb, get_ddb()) logger.info("Imported {} devices.".format(counter))
def import_ddb(): """Import registered devices from the DDB.""" print("Import registered devices fom the DDB...") counter = update_devices(session, AddressOrigin.ogn_ddb, get_ddb()) print("Imported %i devices." % counter)