def setUp(self): super().setUp() # Create basic data and insert self.dd0815 = Device(address="DD0815") self.dd4711 = Device(address="DD4711") self.r01 = Receiver(name="Koenigsdf") self.r02 = Receiver(name="Bene") db.session.add(self.dd0815) db.session.add(self.dd4711) db.session.add(self.r01) db.session.add(self.r02) db.session.commit() # Create beacons and insert self.ab01 = AircraftBeacon(name="FLRDD0815", receiver_name="Koenigsdf", device_id=self.dd0815.id, receiver_id=self.r01.id, timestamp="2017-12-10 10:00:00", location_mgrs_short="89ABC1267", altitude=800) self.ab02 = AircraftBeacon(name="FLRDD0815", receiver_name="Koenigsdf", device_id=self.dd0815.id, receiver_id=self.r01.id, timestamp="2017-12-10 10:00:01", location_mgrs_short="89ABC1267", altitude=850) db.session.add(self.ab01) db.session.add(self.ab02) db.session.commit()
def device_add(user, payload, params): devicetype_id = payload['deviceTypeId'] name = payload['name'] devicetype = get_by_devicetypeid_or_404(user, devicetype_id) check_unique_name(user, name) # Make sure device-role is defined if not devicetype.roles.filter_by(name='device').first(): raise ApiExp.DeviceRoleNotDefined # ToDo: Implement attributeValues for setting initial of meta-data new_device = Device( name=name, serial_number=payload.get('serialNumber', ''), label=payload.get('label', ''), push_url=payload.get('pushURL', ''), owner=user, devicetype=devicetype ) db.session.add(new_device) db.session.commit() return get_ok_response_body( data=dict( id=new_device.deviceid, encryptionKey=new_device.enc_key, deviceToken=new_device.device_token, ) )
def setUp(self): # Create basic data and insert self.dd0815 = Device(address="DD0815") self.dd4711 = Device(address="DD4711") self.koenigsdorf = Airport(name="Koenigsdorf") self.ohlstadt = Airport(name="Ohlstadt") db.session.add(self.dd0815) db.session.add(self.dd4711) db.session.add(self.koenigsdorf) db.session.add(self.ohlstadt) db.session.commit() # Prepare takeoff and landings self.takeoff_koenigsdorf_dd0815 = TakeoffLanding(is_takeoff=True, timestamp="2016-06-01 10:00:00", airport_id=self.koenigsdorf.id, device_id=self.dd0815.id) self.landing_koenigsdorf_dd0815 = TakeoffLanding(is_takeoff=False, timestamp="2016-06-01 10:05:00", airport_id=self.koenigsdorf.id, device_id=self.dd0815.id) self.landing_koenigsdorf_dd0815_later = TakeoffLanding(is_takeoff=False, timestamp="2016-06-02 10:05:00", airport_id=self.koenigsdorf.id, device_id=self.dd0815.id) self.takeoff_ohlstadt_dd4711 = TakeoffLanding(is_takeoff=True, timestamp="2016-06-01 10:00:00", airport_id=self.ohlstadt.id, device_id=self.dd4711.id)
def test_device_info(self): device = Device(name="FLRDD0815", address="DD0815") device_info1 = DeviceInfo(address="DD0815", address_origin=1, registration="D-0815") device_info2 = DeviceInfo(address="DD0815", address_origin=2, registration="15") db.session.add(device) db.session.add(device_info1) db.session.add(device_info2) db.session.commit() self.assertEqual(device.info, device_info1)
def setUp(self): super().setUp() # Prepare Beacons self.ab01 = AircraftBeacon(name="FLRDD4711", receiver_name="Koenigsdf", timestamp="2017-12-10 10:00:01") self.ab02 = AircraftBeacon(name="FLRDD4711", receiver_name="Koenigsdf", timestamp="2017-12-10 10:00:02") self.ab03 = AircraftBeacon(name="FLRDD4711", receiver_name="Koenigsdf", timestamp="2017-12-10 10:00:03") self.ab04 = AircraftBeacon(name="FLRDD4711", receiver_name="Koenigsdf", timestamp="2017-12-10 10:00:04") self.ab05 = AircraftBeacon(name="FLRDD4711", receiver_name="Koenigsdf", timestamp="2017-12-10 10:00:05") self.ab06 = AircraftBeacon(name="FLRDD4711", receiver_name="Koenigsdf", timestamp="2017-12-10 10:00:05") self.rb01 = ReceiverBeacon(name="Koenigsdf", receiver_name="GLIDERN1", timestamp="2017-12-10 09:55:00", altitude=601, version="0.2.5", platform="ARM") self.rb02 = ReceiverBeacon(name="Koenigsdf", receiver_name="GLIDERN1", timestamp="2017-12-10 10:00:00", altitude=601, version="0.2.7", platform="ARM") self.rb03 = ReceiverBeacon(name="Koenigsdf", receiver_name="GLIDERN1", timestamp="2017-12-10 10:05:00", altitude=601, version="0.2.6", platform="ARM") self.r01 = Receiver(name="Koenigsdf") self.r02 = Receiver(name="Bene") self.d01 = Device(address="DD4711") db.session.add(self.r01) db.session.add(self.d01) db.session.commit()
def setUp(self): super().setUp() # Prepare Beacons self.r01 = Receiver(name="Koenigsdf", location_wkt="0101000020E610000061E8FED7A6EE26407F20661C10EA4740", lastseen="2017-12-20 10:00:00", altitude=601, version="0.2.5", platform="ARM") self.r02 = Receiver(name="Bene", location_wkt="0101000020E6100000D5E76A2BF6C72640D4063A6DA0DB4740", lastseen="2017-12-20 09:45:00", altitude=609, version="0.2.7", platform="x64") self.r03 = Receiver(name="Ohlstadt", location_wkt="0101000020E6100000057E678EBF772640A142883E32D44740", lastseen="2017-12-20 10:05:00", altitude=655, version="0.2.6", platform="ARM") db.session.add(self.r01) db.session.add(self.r02) db.session.add(self.r03) db.session.commit() self.d01 = Device(address="DD4711", lastseen="2017-12-20 10:00:02") self.d02 = Device(address="DD0815", lastseen="2017-12-20 09:56:00") db.session.add(self.d01) db.session.add(self.d02) db.session.commit() self.di01 = DeviceInfo(registration="D-4711", competition="Hi", tracked=True, identified=True) db.session.add(self.di01) db.session.commit() self.ab11 = AircraftBeacon( name="FLRDD4711", receiver_name="Koenigsdf", location_wkt="0101000020E6100000211FF46C56ED26402650D7EDC6E94740", aircraft_type=AircraftType.glider_or_motor_glider, timestamp="2017-12-20 10:00:01", track=105, ground_speed=57, climb_rate=-0.5, device_id=self.d01.id, ) self.ab12 = AircraftBeacon( name="FLRDD4711", receiver_name="Koenigsdf", location_wkt="0101000020E6100000806DEA295FED2640347D898BB6E94740", aircraft_type=AircraftType.glider_or_motor_glider, timestamp="2017-12-20 10:00:02", track=123, ground_speed=55, climb_rate=-0.4, altitude=209, device_id=self.d01.id, ) self.ab21 = AircraftBeacon( name="FLRDD0815", receiver_name="Koenigsdf", location_wkt="0101000020E6100000F38B25BF58F22640448B6CE7FBE94740", aircraft_type=AircraftType.powered_aircraft, timestamp="2017-12-20 09:54:30", track=280, ground_speed=80, climb_rate=-2.9, device_id=self.d02.id, ) self.ab22 = AircraftBeacon( name="FLRDD0815", receiver_name="Bene", location_wkt="0101000020E6100000A5E8482EFFF12640DC1EAA16FEE94740", aircraft_type=AircraftType.powered_aircraft, timestamp="2017-12-20 09:56:00", track=270, ground_speed=77, climb_rate=-1.5, altitude=543, device_id=self.d02.id, ) db.session.add(self.ab11) db.session.add(self.ab12) db.session.add(self.ab21) db.session.add(self.ab22) db.session.commit() self.rc11 = ReceiverCoverage( location_mgrs_short="32TPU8312", date=date(2017, 12, 20), max_signal_quality=10, max_altitude=1000, min_altitude=600, aircraft_beacon_count=20, device_count=2, receiver=self.r01 ) self.rc12 = ReceiverCoverage( location_mgrs_short="32TPU8434", date=date(2017, 12, 20), max_signal_quality=10, max_altitude=1000, min_altitude=600, aircraft_beacon_count=20, device_count=2, receiver=self.r01 ) self.rc12 = ReceiverCoverage( location_mgrs_short="32TPU8434", date=date(2017, 12, 21), max_signal_quality=10, max_altitude=1000, min_altitude=600, aircraft_beacon_count=20, device_count=2, receiver=self.r01 ) self.rc21 = ReceiverCoverage( location_mgrs_short="32TPU8512", date=date(2017, 12, 20), max_signal_quality=10, max_altitude=1000, min_altitude=600, aircraft_beacon_count=20, device_count=2, receiver=self.r02 ) db.session.add(self.rc11) db.session.add(self.rc12) db.session.add(self.rc21) db.session.commit()
def test_expiry_date(self): device = Device(name="FLRDD0815", address="DD0815", software_version=6.42) self.assertEqual(device.expiry_date(), datetime.date(2019, 10, 31))