def create_event(self, time, uas_in_air):
     """Create a TakeoffOrLandingEvent for test user."""
     event = TakeoffOrLandingEvent(user=self.user1, uas_in_air=uas_in_air)
     event.save()
     event.timestamp = time
     event.save()
     return event
Ejemplo n.º 2
0
    def test_kml_simple(self):
        coordinates = [
            (-76.0, 38.0, 0.0),
            (-76.0, 38.0, 10.0),
            (-76.0, 38.0, 20.0),
            (-76.0, 38.0, 30.0),
            (-76.0, 38.0, 100.0),
            (-76.0, 38.0, 30.0),
            (-76.0, 38.0, 60.0),
        ]
        # Create Coordinates
        start = TakeoffOrLandingEvent(user=self.user, uas_in_air=True)
        start.save()
        for coord in coordinates:
            self.create_log_element(*coord)
        end = TakeoffOrLandingEvent(user=self.user, uas_in_air=False)
        end.save()

        kml = Kml()
        UasTelemetry.kml(user=self.user,
                         logs=UasTelemetry.by_user(self.user),
                         kml=kml,
                         kml_doc=kml)
        for coord in coordinates:
            tag = self.coord_format.format(coord[1], coord[0],
                                           units.feet_to_meters(coord[2]))
            self.assertTrue(tag in kml.kml())
Ejemplo n.º 3
0
 def create_event(self, time, uas_in_air):
     """Create a TakeoffOrLandingEvent for test user."""
     event = TakeoffOrLandingEvent(user=self.user1, uas_in_air=uas_in_air)
     event.save()
     event.timestamp = time
     event.save()
     return event
Ejemplo n.º 4
0
    def test_kml_simple(self):
        coordinates = [
            (-76.0, 38.0, 0.0),
            (-76.0, 38.0, 10.0),
            (-76.0, 38.0, 20.0),
            (-76.0, 38.0, 30.0),
            (-76.0, 38.0, 100.0),
            (-76.0, 38.0, 30.0),
            (-76.0, 38.0, 60.0),
        ]
        # Create Coordinates
        start = TakeoffOrLandingEvent(user=self.user, uas_in_air=True)
        start.save()
        for coord in coordinates:
            self.create_log_element(*coord)
        end = TakeoffOrLandingEvent(user=self.user, uas_in_air=False)
        end.save()

        kml = Kml()
        UasTelemetry.kml(user=self.user,
                         logs=UasTelemetry.by_user(self.user),
                         kml=kml,
                         kml_doc=kml)
        for coord in coordinates:
            tag = self.coord_format.format(coord[1], coord[0],
                                           units.feet_to_meters(coord[2]))
            self.assertTrue(tag in kml.kml())
Ejemplo n.º 5
0
    def put(self, request, pk):
        """PUT allows updating status."""
        try:
            user = User.objects.get(pk=int(pk))
        except User.DoesNotExist:
            return HttpResponseBadRequest('Unknown team %s' % pk)
        try:
            data = json.loads(request.body)
        except ValueError:
            return HttpResponseBadRequest('Invalid JSON: %s' % request.body)

        # Potential events to update.
        takeoff_event = None
        clock_event = None
        # Update whether UAS is in air.
        if 'in_air' in data:
            in_air = data['in_air']
            if not isinstance(in_air, bool):
                return HttpResponseBadRequest('in_air must be boolean')

            currently_in_air = TakeoffOrLandingEvent.user_in_air(user)
            # New event only necessary if changing status
            if currently_in_air != in_air:
                takeoff_event = TakeoffOrLandingEvent(user=user,
                                                      uas_in_air=in_air)
        # Request was valid. Save updates.
        if takeoff_event:
            takeoff_event.save()
        if clock_event:
            clock_event.save()

        return HttpResponse(json.dumps(user_json(user)),
                            content_type="application/json")
 def create_event(self, time, uas_in_air, mission=None):
     """Create a TakeoffOrLandingEvent for test user."""
     if mission is None:
         mission = self.mission
     event = TakeoffOrLandingEvent(
         user=self.user1, mission=mission, uas_in_air=uas_in_air)
     event.save()
     event.timestamp = time
     event.save()
     return event
Ejemplo n.º 7
0
    def put(self, request, pk):
        """PUT allows updating status."""
        try:
            user = User.objects.get(pk=int(pk))
        except User.DoesNotExist:
            return HttpResponseBadRequest('Unknown team %s' % pk)
        try:
            data = json.loads(request.body)
        except ValueError:
            return HttpResponseBadRequest('Invalid JSON: %s' % request.body)

        # Potential events to update.
        takeoff_event = None
        clock_event = None
        # Update whether UAS is in air.
        if 'in_air' in data:
            in_air = data['in_air']
            if not isinstance(in_air, bool):
                return HttpResponseBadRequest('in_air must be boolean')

            currently_in_air = TakeoffOrLandingEvent.user_in_air(user)
            # New event only necessary if changing status
            if currently_in_air != in_air:
                takeoff_event = TakeoffOrLandingEvent(
                    user=user, uas_in_air=in_air)
        # Update whether UAS in on clock or timeout.
        if 'on_clock' in data or 'on_timeout' in data:
            currently_on_clock = MissionClockEvent.user_on_clock(user)

            currently_on_timeout = MissionClockEvent.user_on_timeout(user)
            on_clock = data.get('on_clock', currently_on_clock)
            on_timeout = data.get('on_timeout', currently_on_timeout)
            if (not isinstance(on_clock, bool) or
                    not isinstance(on_timeout, bool)):
                return HttpResponseBadRequest(
                    'on_clock and on_timeout must be boolean.')
            if on_clock and on_timeout:
                return HttpResponseBadRequest(
                    'Cannot be on mission clock and on timeout.')
            # New event only necessary if changing status
            if (on_clock != currently_on_clock or
                    on_timeout != currently_on_timeout):
                clock_event = MissionClockEvent(
                    user=user,
                    team_on_clock=on_clock,
                    team_on_timeout=on_timeout)
        # Request was valid. Save updates.
        if takeoff_event:
            takeoff_event.save()
        if clock_event:
            clock_event.save()

        return HttpResponse(
            json.dumps(user_json(user)), content_type="application/json")
Ejemplo n.º 8
0
    def put(self, request, pk):
        """PUT allows updating status."""
        try:
            user = User.objects.get(pk=int(pk))
        except User.DoesNotExist:
            return HttpResponseBadRequest('Unknown team %s' % pk)
        try:
            data = json.loads(request.body)
        except ValueError:
            return HttpResponseBadRequest('Invalid JSON: %s' % request.body)

        # Potential events to update.
        takeoff_event = None
        clock_event = None
        # Update whether UAS is in air.
        if 'in_air' in data:
            in_air = data['in_air']
            if not isinstance(in_air, bool):
                return HttpResponseBadRequest('in_air must be boolean')

            currently_in_air = TakeoffOrLandingEvent.user_in_air(user)
            # New event only necessary if changing status
            if currently_in_air != in_air:
                takeoff_event = TakeoffOrLandingEvent(user=user,
                                                      uas_in_air=in_air)
        # Update whether UAS in on clock or timeout.
        if 'on_clock' in data or 'on_timeout' in data:
            currently_on_clock = MissionClockEvent.user_on_clock(user)

            currently_on_timeout = MissionClockEvent.user_on_timeout(user)
            on_clock = data.get('on_clock', currently_on_clock)
            on_timeout = data.get('on_timeout', currently_on_timeout)
            if (not isinstance(on_clock, bool) or
                    not isinstance(on_timeout, bool)):
                return HttpResponseBadRequest(
                    'on_clock and on_timeout must be boolean.')
            if on_clock and on_timeout:
                return HttpResponseBadRequest(
                    'Cannot be on mission clock and on timeout.')
            # New event only necessary if changing status
            if (on_clock != currently_on_clock or
                    on_timeout != currently_on_timeout):
                clock_event = MissionClockEvent(user=user,
                                                team_on_clock=on_clock,
                                                team_on_timeout=on_timeout)
        # Request was valid. Save updates.
        if takeoff_event:
            takeoff_event.save()
        if clock_event:
            clock_event.save()

        return HttpResponse(
            json.dumps(user_json(user)),
            content_type="application/json")
Ejemplo n.º 9
0
    def test_kml_simple(self):
        coordinates = [
            (0, -76.0, 38.0, 0.0, 0),
            (1, -76.0, 38.0, 10.0, 0),
            (2, -76.0, 38.0, 20.0, 0),
            (3, -76.0, 38.0, 30.0, 0),
            (4, -76.0, 38.0, 100.0, 0),
            (5, -76.0, 38.0, 30.0, 0),
            (6, -76.0, 38.0, 60.0, 0),
        ]
        # Create Coordinates
        start = TakeoffOrLandingEvent(user=self.user, uas_in_air=True)
        start.save()
        start.timestamp = self.now
        start.save()
        for coord in coordinates:
            self.create_log_element(*coord)
        end = TakeoffOrLandingEvent(user=self.user, uas_in_air=False)
        end.save()
        end.timestamp = self.now + datetime.timedelta(seconds=7)
        end.save()

        kml = Kml()
        UasTelemetry.kml(
            user=self.user,
            logs=UasTelemetry.by_user(self.user),
            kml=kml,
            kml_doc=kml.document)
        for coord in coordinates:
            tag = self.coord_format.format(coord[2], coord[1],
                                           units.feet_to_meters(coord[3]))
            self.assertTrue(tag in kml.kml())
Ejemplo n.º 10
0
    def test_actionable_submission(self):
        """Tests actionable_submission correctly filters submissions."""
        # t1 created and updated before take off.
        t1 = Target(user=self.user, target_type=TargetType.standard)
        t1.save()
        t1.alphanumeric = 'A'
        t1.save()

        # t2 created before take off and updated in flight.
        t2 = Target(user=self.user, target_type=TargetType.standard)
        t2.save()

        event = TakeoffOrLandingEvent(user=self.user, uas_in_air=True)
        event.save()

        t2.alphanumeric = 'A'
        t2.save()

        # t3 created and updated in flight.
        t3 = Target(user=self.user, target_type=TargetType.standard)
        t3.save()
        t3.alphanumeric = 'A'
        t3.save()

        # t4 created in flight and updated after landing.
        t4 = Target(user=self.user, target_type=TargetType.standard)
        t4.save()

        event = TakeoffOrLandingEvent(user=self.user, uas_in_air=False)
        event.save()

        t4.alphanumeric = 'A'
        t4.save()

        # t5 created and updated after landing.
        t5 = Target(user=self.user, target_type=TargetType.standard)
        t5.save()
        t5.alphanumeric = 'A'
        t5.save()

        # t6 created and updated in second flight.
        event = TakeoffOrLandingEvent(user=self.user, uas_in_air=True)
        event.save()
        t6 = Target(user=self.user, target_type=TargetType.standard)
        t6.save()
        t6.alphanumeric = 'A'
        t6.save()
        event = TakeoffOrLandingEvent(user=self.user, uas_in_air=False)
        event.save()

        self.assertFalse(t1.actionable_submission())
        self.assertFalse(t2.actionable_submission())
        self.assertTrue(t3.actionable_submission())
        self.assertFalse(t4.actionable_submission())
        self.assertFalse(t5.actionable_submission())
        self.assertFalse(t6.actionable_submission())
Ejemplo n.º 11
0
    def create_data(self):
        """Create a basic sample dataset."""
        self.user1 = User.objects.create_user('user1', '*****@*****.**',
                                              'testpass')
        self.user1.save()

        self.user2 = User.objects.create_user('user2', '*****@*****.**',
                                              'testpass')
        self.user2.save()

        # Mission
        pos = GpsPosition()
        pos.latitude = 10
        pos.longitude = 100
        pos.save()
        wpt = Waypoint()
        wpt.order = 10
        wpt.latitude = 10
        wpt.longitude = 100
        wpt.altitude_msl = 1000
        wpt.save()
        self.mission = MissionConfig()
        self.mission.home_pos = pos
        self.mission.emergent_last_known_pos = pos
        self.mission.off_axis_odlc_pos = pos
        self.mission.air_drop_pos = pos
        self.mission.save()
        self.mission.mission_waypoints.add(wpt)
        self.mission.search_grid_points.add(wpt)
        self.mission.save()

        # user1 is flying
        event = TakeoffOrLandingEvent(user=self.user1,
                                      mission=self.mission,
                                      uas_in_air=True)
        event.save()

        # user2 has landed
        event = TakeoffOrLandingEvent(user=self.user2,
                                      mission=self.mission,
                                      uas_in_air=True)
        event.save()
        event = TakeoffOrLandingEvent(user=self.user2,
                                      mission=self.mission,
                                      uas_in_air=False)
        event.save()

        # user2 is active
        self.timestamp = timezone.now()

        self.telem = UasTelemetry(user=self.user2,
                                  latitude=38.6462,
                                  longitude=-76.2452,
                                  altitude_msl=0,
                                  uas_heading=90)
        self.telem.save()
        self.telem.timestamp = dateutil.parser.parse(
            u'2016-10-01T00:00:00.0+00:00')

        self.telem.save()
Ejemplo n.º 12
0
    def create_data(self):
        """Create a basic sample dataset."""
        self.user1 = User.objects.create_user('user1', '*****@*****.**',
                                              'testpass')
        self.user1.save()

        self.user2 = User.objects.create_user('user2', '*****@*****.**',
                                              'testpass')
        self.user2.save()

        # user1 is flying
        event = TakeoffOrLandingEvent(user=self.user1, uas_in_air=True)
        event.save()

        # user2 has landed
        event = TakeoffOrLandingEvent(user=self.user2, uas_in_air=True)
        event.save()
        event = TakeoffOrLandingEvent(user=self.user2, uas_in_air=False)
        event.save()

        # user2 is active
        self.timestamp = timezone.now()

        gps = GpsPosition(latitude=38.6462, longitude=-76.2452)
        gps.save()

        pos = AerialPosition(gps_position=gps, altitude_msl=0)
        pos.save()

        self.telem = UasTelemetry(user=self.user2,
                                  uas_position=pos,
                                  uas_heading=90)
        self.telem.save()
        self.telem.timestamp = dateutil.parser.parse(
            u'2016-10-01T00:00:00.0+00:00')

        self.telem.save()
Ejemplo n.º 13
0
    def test_actionable_submission(self):
        """Tests actionable_submission correctly filters submissions."""
        # t1 created and updated before take off.
        t1 = Odlc(mission=self.mission,
                  user=self.user,
                  odlc_type=interop_api_pb2.Odlc.STANDARD)
        t1.save()
        t1.alphanumeric = 'A'
        t1.update_last_modified()
        t1.save()

        # t2 created before take off and updated in flight.
        t2 = Odlc(mission=self.mission,
                  user=self.user,
                  odlc_type=interop_api_pb2.Odlc.STANDARD)
        t2.save()

        event = TakeoffOrLandingEvent(user=self.user,
                                      mission=self.mission,
                                      uas_in_air=True)
        event.save()

        t2.alphanumeric = 'A'
        t2.update_last_modified()
        t2.save()

        # t3 created and updated in flight.
        t3 = Odlc(mission=self.mission,
                  user=self.user,
                  odlc_type=interop_api_pb2.Odlc.STANDARD)
        t3.save()
        t3.alphanumeric = 'A'
        t3.update_last_modified()
        t3.save()

        # t4 created in flight and updated after landing.
        t4 = Odlc(mission=self.mission,
                  user=self.user,
                  odlc_type=interop_api_pb2.Odlc.STANDARD)
        t4.save()

        event = TakeoffOrLandingEvent(user=self.user,
                                      mission=self.mission,
                                      uas_in_air=False)
        event.save()

        t4.alphanumeric = 'A'
        t4.update_last_modified()
        t4.save()

        # t5 created and updated after landing.
        t5 = Odlc(mission=self.mission,
                  user=self.user,
                  odlc_type=interop_api_pb2.Odlc.STANDARD)
        t5.save()
        t5.alphanumeric = 'A'
        t5.update_last_modified()
        t5.save()

        # t6 created and updated in second flight.
        event = TakeoffOrLandingEvent(user=self.user,
                                      mission=self.mission,
                                      uas_in_air=True)
        event.save()
        t6 = Odlc(mission=self.mission,
                  user=self.user,
                  odlc_type=interop_api_pb2.Odlc.STANDARD)
        t6.save()
        t6.alphanumeric = 'A'
        t6.update_last_modified()
        t6.save()
        event = TakeoffOrLandingEvent(user=self.user,
                                      mission=self.mission,
                                      uas_in_air=False)
        event.save()

        # t7 which is not actionable.
        event = TakeoffOrLandingEvent(user=self.user,
                                      mission=self.mission,
                                      uas_in_air=True)
        event.save()
        t7 = Odlc(mission=self.mission,
                  user=self.user,
                  odlc_type=interop_api_pb2.Odlc.STANDARD)
        event = TakeoffOrLandingEvent(user=self.user,
                                      mission=self.mission,
                                      uas_in_air=False)
        event.save()

        flights = TakeoffOrLandingEvent.flights(self.mission, self.user)

        self.assertFalse(t1.actionable_submission(flights))
        self.assertFalse(t2.actionable_submission(flights))
        self.assertTrue(t3.actionable_submission(flights))
        self.assertFalse(t4.actionable_submission(flights))
        self.assertFalse(t5.actionable_submission(flights))
        self.assertFalse(t6.actionable_submission(flights))
        self.assertFalse(t7.actionable_submission(flights))
Ejemplo n.º 14
0
    def setUp(self):
        """Setup the test case."""
        super(TestOdlcEvaluator, self).setUp()
        self.maxDiff = None
        self.user = User.objects.create_user('user', '*****@*****.**',
                                             'pass')

        l1 = GpsPosition(latitude=38, longitude=-76)
        l1.save()
        l2 = GpsPosition(latitude=38.0003, longitude=-76)
        l2.save()
        l3 = GpsPosition(latitude=-38, longitude=76)
        l3.save()
        l4 = GpsPosition(latitude=0, longitude=0)
        l4.save()

        # Mission
        pos = GpsPosition()
        pos.latitude = 10
        pos.longitude = 100
        pos.save()
        wpt = Waypoint()
        wpt.order = 10
        wpt.latitude = 10
        wpt.longitude = 100
        wpt.altitude_msl = 1000
        wpt.save()
        self.mission = MissionConfig()
        self.mission.home_pos = pos
        self.mission.lost_comms_pos = pos
        self.mission.emergent_last_known_pos = pos
        self.mission.off_axis_odlc_pos = pos
        self.mission.map_center_pos = pos
        self.mission.map_height_ft = 1
        self.mission.air_drop_pos = pos
        self.mission.ugv_drive_pos = pos
        self.mission.save()
        self.mission.mission_waypoints.add(wpt)
        self.mission.search_grid_points.add(wpt)
        self.mission.save()

        event = TakeoffOrLandingEvent(user=self.user,
                                      mission=self.mission,
                                      uas_in_air=True)
        event.save()

        # A odlc worth full points.
        self.submit1 = Odlc(mission=self.mission,
                            user=self.user,
                            odlc_type=interop_api_pb2.Odlc.STANDARD,
                            location=l1,
                            orientation=interop_api_pb2.Odlc.S,
                            shape=interop_api_pb2.Odlc.SQUARE,
                            shape_color=interop_api_pb2.Odlc.WHITE,
                            alphanumeric='ABC',
                            alphanumeric_color=interop_api_pb2.Odlc.BLACK,
                            description='Submit test odlc 1',
                            description_approved=True,
                            autonomous=True,
                            thumbnail_approved=True)
        self.submit1.save()
        self.real1 = Odlc(mission=self.mission,
                          user=self.user,
                          odlc_type=interop_api_pb2.Odlc.STANDARD,
                          location=l1,
                          orientation=interop_api_pb2.Odlc.S,
                          shape=interop_api_pb2.Odlc.SQUARE,
                          shape_color=interop_api_pb2.Odlc.WHITE,
                          alphanumeric='ABC',
                          alphanumeric_color=interop_api_pb2.Odlc.BLACK,
                          description='Real odlc 1')
        self.real1.save()

        # A odlc worth less than full points.
        self.submit2 = Odlc(
            mission=self.mission,
            user=self.user,
            odlc_type=interop_api_pb2.Odlc.STANDARD,
            location=l1,
            orientation=interop_api_pb2.Odlc.N,
            shape=interop_api_pb2.Odlc.CIRCLE,
            shape_color=interop_api_pb2.Odlc.WHITE,
            # alphanumeric set below
            alphanumeric_color=interop_api_pb2.Odlc.BLACK,
            description='Submit test odlc 2',
            autonomous=False,
            thumbnail_approved=True)
        self.submit2.save()
        self.real2 = Odlc(mission=self.mission,
                          user=self.user,
                          odlc_type=interop_api_pb2.Odlc.STANDARD,
                          location=l2,
                          orientation=interop_api_pb2.Odlc.S,
                          shape=interop_api_pb2.Odlc.TRIANGLE,
                          shape_color=interop_api_pb2.Odlc.WHITE,
                          alphanumeric='ABC',
                          alphanumeric_color=interop_api_pb2.Odlc.BLACK,
                          description='Real test odlc 2')
        self.real2.save()

        # A odlc worth no points, so unmatched.
        self.submit3 = Odlc(mission=self.mission,
                            user=self.user,
                            odlc_type=interop_api_pb2.Odlc.STANDARD,
                            location=l4,
                            orientation=interop_api_pb2.Odlc.NW,
                            shape=interop_api_pb2.Odlc.PENTAGON,
                            shape_color=interop_api_pb2.Odlc.GRAY,
                            alphanumeric='XYZ',
                            alphanumeric_color=interop_api_pb2.Odlc.ORANGE,
                            description='Incorrect description',
                            autonomous=False,
                            thumbnail_approved=True)
        self.submit3.save()
        self.real3 = Odlc(
            mission=self.mission,
            user=self.user,
            odlc_type=interop_api_pb2.Odlc.STANDARD,
            orientation=interop_api_pb2.Odlc.E,
            shape=interop_api_pb2.Odlc.SEMICIRCLE,
            shape_color=interop_api_pb2.Odlc.YELLOW,
            alphanumeric='LMN',
            # alphanumeric_color set below
            location=l3,
            description='Test odlc 3')
        self.real3.save()

        # Odlcs without approved image has no match value.
        self.submit4 = Odlc(mission=self.mission,
                            user=self.user,
                            odlc_type=interop_api_pb2.Odlc.EMERGENT,
                            location=l1,
                            description='Test odlc 4',
                            autonomous=False,
                            thumbnail_approved=False)
        self.submit4.save()
        self.real4 = Odlc(mission=self.mission,
                          user=self.user,
                          odlc_type=interop_api_pb2.Odlc.EMERGENT,
                          location=l1,
                          description='Test odlc 4')
        self.real4.save()

        # A odlc without location worth fewer points.
        self.submit5 = Odlc(mission=self.mission,
                            user=self.user,
                            odlc_type=interop_api_pb2.Odlc.STANDARD,
                            orientation=interop_api_pb2.Odlc.N,
                            shape=interop_api_pb2.Odlc.TRAPEZOID,
                            shape_color=interop_api_pb2.Odlc.PURPLE,
                            alphanumeric='PQR',
                            alphanumeric_color=interop_api_pb2.Odlc.BLUE,
                            description='Test odlc 5',
                            autonomous=False,
                            thumbnail_approved=True)
        self.submit5.save()
        self.real5 = Odlc(mission=self.mission,
                          user=self.user,
                          odlc_type=interop_api_pb2.Odlc.STANDARD,
                          location=l1,
                          orientation=interop_api_pb2.Odlc.N,
                          shape=interop_api_pb2.Odlc.TRAPEZOID,
                          shape_color=interop_api_pb2.Odlc.PURPLE,
                          alphanumeric='PQR',
                          alphanumeric_color=interop_api_pb2.Odlc.BLUE,
                          description='Test odlc 5')
        self.real5.save()

        # Emergent odlc with correct description.
        self.submit6 = Odlc(mission=self.mission,
                            user=self.user,
                            odlc_type=interop_api_pb2.Odlc.EMERGENT,
                            location=l1,
                            description='Submit test odlc 6',
                            description_approved=True,
                            autonomous=True,
                            thumbnail_approved=True)
        self.submit6.save()
        self.real6 = Odlc(mission=self.mission,
                          user=self.user,
                          odlc_type=interop_api_pb2.Odlc.EMERGENT,
                          location=l1,
                          description='Real odlc 1',
                          description_approved=True)
        self.real6.save()

        event = TakeoffOrLandingEvent(user=self.user,
                                      mission=self.mission,
                                      uas_in_air=False)
        event.save()

        # submit2 updated after landing.
        self.submit2.alphanumeric = 'ABC'
        self.submit2.update_last_modified()
        self.submit2.save()
        self.submit2.update_last_modified()
        self.submit3.alphanumeric_color = interop_api_pb2.Odlc.YELLOW
        self.submit3.update_last_modified()
        self.submit3.save()
        # Unused but not unmatched odlc.
        self.submit7 = Odlc(mission=self.mission,
                            user=self.user,
                            odlc_type=interop_api_pb2.Odlc.STANDARD,
                            location=l4,
                            alphanumeric_color=interop_api_pb2.Odlc.BLACK,
                            description='Submit unused test odlc 1',
                            autonomous=False,
                            thumbnail_approved=True)
        self.submit7.save()

        self.submitted_odlcs = [
            self.submit7, self.submit6, self.submit5, self.submit4,
            self.submit3, self.submit2, self.submit1
        ]
        self.real_odlcs = [
            self.real1, self.real2, self.real3, self.real4, self.real5,
            self.real6
        ]

        self.flights = TakeoffOrLandingEvent.flights(self.mission, self.user)
Ejemplo n.º 15
0
    def test_actionable_submission(self):
        """Tests actionable_submission correctly filters submissions."""
        # t1 created and updated before take off.
        t1 = Odlc(user=self.user, odlc_type=OdlcType.standard)
        t1.save()
        t1.alphanumeric = 'A'
        t1.update_last_modified()
        t1.save()

        # t2 created before take off and updated in flight.
        t2 = Odlc(user=self.user, odlc_type=OdlcType.standard)
        t2.save()

        event = TakeoffOrLandingEvent(user=self.user, uas_in_air=True)
        event.save()

        t2.alphanumeric = 'A'
        t2.update_last_modified()
        t2.save()

        # t3 created and updated in flight.
        t3 = Odlc(user=self.user, odlc_type=OdlcType.standard)
        t3.save()
        t3.alphanumeric = 'A'
        t3.update_last_modified()
        t3.save()

        # t4 created in flight and updated after landing.
        t4 = Odlc(user=self.user, odlc_type=OdlcType.standard)
        t4.save()

        event = TakeoffOrLandingEvent(user=self.user, uas_in_air=False)
        event.save()

        t4.alphanumeric = 'A'
        t4.update_last_modified()
        t4.save()

        # t5 created and updated after landing.
        t5 = Odlc(user=self.user, odlc_type=OdlcType.standard)
        t5.save()
        t5.alphanumeric = 'A'
        t5.update_last_modified()
        t5.save()

        # t6 created and updated in second flight.
        event = TakeoffOrLandingEvent(user=self.user, uas_in_air=True)
        event.save()
        t6 = Odlc(user=self.user, odlc_type=OdlcType.standard)
        t6.save()
        t6.alphanumeric = 'A'
        t6.update_last_modified()
        t6.save()
        event = TakeoffOrLandingEvent(user=self.user, uas_in_air=False)
        event.save()

        # t7 with actionable_override set.
        event = TakeoffOrLandingEvent(user=self.user, uas_in_air=True)
        event.save()
        event = TakeoffOrLandingEvent(user=self.user, uas_in_air=False)
        event.save()
        t7 = Odlc(user=self.user,
                  odlc_type=OdlcType.standard,
                  actionable_override=True)
        t7.save()

        self.assertFalse(t1.actionable_submission())
        self.assertFalse(t2.actionable_submission())
        self.assertTrue(t3.actionable_submission())
        self.assertFalse(t4.actionable_submission())
        self.assertFalse(t5.actionable_submission())
        self.assertFalse(t6.actionable_submission())
        self.assertTrue(t7.actionable_submission())
Ejemplo n.º 16
0
    def setUp(self):
        """Setup the test case."""
        super(TestOdlcEvaluator, self).setUp()
        self.maxDiff = None
        self.user = User.objects.create_user('user', '*****@*****.**',
                                             'pass')

        l1 = GpsPosition(latitude=38, longitude=-76)
        l1.save()
        l2 = GpsPosition(latitude=38.0003, longitude=-76)
        l2.save()
        l3 = GpsPosition(latitude=-38, longitude=76)
        l3.save()
        l4 = GpsPosition(latitude=0, longitude=0)
        l4.save()

        event = TakeoffOrLandingEvent(user=self.user, uas_in_air=True)
        event.save()

        # A odlc worth full points.
        self.submit1 = Odlc(user=self.user,
                            odlc_type=OdlcType.standard,
                            location=l1,
                            orientation=Orientation.s,
                            shape=Shape.square,
                            background_color=Color.white,
                            alphanumeric='ABC',
                            alphanumeric_color=Color.black,
                            description='Submit test odlc 1',
                            description_approved=True,
                            autonomous=True,
                            thumbnail_approved=True)
        self.submit1.save()
        self.real1 = Odlc(user=self.user,
                          odlc_type=OdlcType.standard,
                          location=l1,
                          orientation=Orientation.s,
                          shape=Shape.square,
                          background_color=Color.white,
                          alphanumeric='ABC',
                          alphanumeric_color=Color.black,
                          description='Real odlc 1')
        self.real1.save()

        # A odlc worth less than full points.
        self.submit2 = Odlc(
            user=self.user,
            odlc_type=OdlcType.standard,
            location=l1,
            orientation=Orientation.n,
            shape=Shape.circle,
            background_color=Color.white,
            # alphanumeric set below
            alphanumeric_color=Color.black,
            description='Submit test odlc 2',
            autonomous=False,
            thumbnail_approved=True)
        self.submit2.save()
        self.real2 = Odlc(user=self.user,
                          odlc_type=OdlcType.standard,
                          location=l2,
                          orientation=Orientation.s,
                          shape=Shape.triangle,
                          background_color=Color.white,
                          alphanumeric='ABC',
                          alphanumeric_color=Color.black,
                          description='Real test odlc 2')
        self.real2.save()

        # A odlc worth no points, so unmatched.
        self.submit3 = Odlc(user=self.user,
                            odlc_type=OdlcType.standard,
                            location=l4,
                            orientation=Orientation.nw,
                            shape=Shape.pentagon,
                            background_color=Color.gray,
                            alphanumeric='XYZ',
                            alphanumeric_color=Color.orange,
                            description='Incorrect description',
                            autonomous=False,
                            thumbnail_approved=True)
        self.submit3.save()
        self.real3 = Odlc(
            user=self.user,
            odlc_type=OdlcType.standard,
            orientation=Orientation.e,
            shape=Shape.semicircle,
            background_color=Color.yellow,
            alphanumeric='LMN',
            # alphanumeric_color set below
            location=l3,
            description='Test odlc 3')
        self.real3.save()

        # Odlcs without approved image has no match value.
        self.submit4 = Odlc(user=self.user,
                            odlc_type=OdlcType.emergent,
                            location=l1,
                            description='Test odlc 4',
                            autonomous=False,
                            thumbnail_approved=False)
        self.submit4.save()
        self.real4 = Odlc(user=self.user,
                          odlc_type=OdlcType.emergent,
                          location=l1,
                          description='Test odlc 4')
        self.real4.save()

        # A odlc without location worth fewer points.
        self.submit5 = Odlc(user=self.user,
                            odlc_type=OdlcType.standard,
                            orientation=Orientation.n,
                            shape=Shape.trapezoid,
                            background_color=Color.purple,
                            alphanumeric='PQR',
                            alphanumeric_color=Color.blue,
                            description='Test odlc 5',
                            autonomous=False,
                            thumbnail_approved=True)
        self.submit5.save()
        self.real5 = Odlc(user=self.user,
                          odlc_type=OdlcType.standard,
                          location=l1,
                          orientation=Orientation.n,
                          shape=Shape.trapezoid,
                          background_color=Color.purple,
                          alphanumeric='PQR',
                          alphanumeric_color=Color.blue,
                          description='Test odlc 5')
        self.real5.save()

        # Emergent odlc with correct description.
        self.submit6 = Odlc(user=self.user,
                            odlc_type=OdlcType.emergent,
                            location=l1,
                            description='Submit test odlc 6',
                            description_approved=True,
                            autonomous=True,
                            thumbnail_approved=True)
        self.submit6.save()
        self.real6 = Odlc(user=self.user,
                          odlc_type=OdlcType.emergent,
                          location=l1,
                          description='Real odlc 1',
                          description_approved=True)
        self.real6.save()

        event = TakeoffOrLandingEvent(user=self.user, uas_in_air=False)
        event.save()

        # submit2 updated after landing.
        self.submit2.alphanumeric = 'ABC'
        self.submit2.update_last_modified()
        self.submit2.save()
        self.submit2.update_last_modified()
        self.submit3.alphanumeric_color = Color.yellow
        self.submit3.update_last_modified()
        self.submit3.save()
        # Unused but not unmatched odlc.
        self.submit7 = Odlc(user=self.user,
                            odlc_type=OdlcType.standard,
                            location=l4,
                            alphanumeric_color=Color.black,
                            description='Submit unused test odlc 1',
                            autonomous=False,
                            thumbnail_approved=True)
        self.submit7.save()

        self.submitted_odlcs = [
            self.submit7, self.submit6, self.submit5, self.submit4,
            self.submit3, self.submit2, self.submit1
        ]
        self.real_odlcs = [
            self.real1, self.real2, self.real3, self.real4, self.real5,
            self.real6
        ]
 def test_unicode(self):
     """Tests the unicode method executes."""
     log = TakeoffOrLandingEvent(user=self.user1, uas_in_air=True)
     log.save()
     self.assertIsNotNone(log.__unicode__())
 def test_unicode(self):
     """Tests the unicode method executes."""
     log = TakeoffOrLandingEvent(user=self.user1, uas_in_air=True)
     log.save()
     self.assertIsNotNone(log.__unicode__())