コード例 #1
0
ファイル: test_utils.py プロジェクト: matburnham/ogn-python
 def test_get_trackable(self):
     devices = get_ddb(os.path.dirname(__file__) + "/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)
コード例 #2
0
ファイル: test_utils.py プロジェクト: matburnham/ogn-python
    def test_get_ddb_from_file(self):
        devices = get_ddb(os.path.dirname(__file__) + "/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)
コード例 #3
0
def update_device_infos(session, address_origin, path=None):
    if address_origin == DeviceInfoOrigin.FLARMNET:
        device_infos = get_flarmnet(fln_file=path)
    else:
        device_infos = get_ddb(csv_file=path)

    session.query(DeviceInfo).filter(
        DeviceInfo.address_origin == address_origin).delete(
            synchronize_session="fetch")
    session.commit()

    for device_info in device_infos:
        device_info.address_origin = address_origin

    session.bulk_save_objects(device_infos)
    session.commit()

    return len(device_infos)
コード例 #4
0
ファイル: test_utils.py プロジェクト: matburnham/ogn-python
 def test_get_devices(self):
     devices = get_ddb()
     self.assertGreater(len(devices), 1000)