예제 #1
0
    def test_last_modified_time(self):
        """Last modified time is set on creation and changes every update."""
        t = Odlc(user=self.user, odlc_type=OdlcType.standard)
        t.save()

        orig = t.last_modified_time
        self.assertIsNotNone(orig)

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

        self.assertGreater(t.last_modified_time, orig)
예제 #2
0
    def test_creation_time(self):
        """Creation time is set on creation and doesn't change on update."""
        t = Odlc(user=self.user, odlc_type=OdlcType.standard)
        t.save()

        orig = t.creation_time
        self.assertIsNotNone(orig)

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

        self.assertEqual(orig, t.creation_time)
예제 #3
0
    def test_similar_classifications_ratio(self):
        """Tests similar classification ratios are computed correctly."""
        # Test equal standard odlcs.
        l = GpsPosition(latitude=38, longitude=-76)
        l.save()
        t1 = Odlc(mission=self.mission,
                  user=self.user,
                  odlc_type=interop_api_pb2.Odlc.STANDARD,
                  location=l,
                  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='Test odlc',
                  description_approved=True,
                  autonomous=True)
        t1.save()
        t2 = Odlc(mission=self.mission,
                  user=self.user,
                  odlc_type=interop_api_pb2.Odlc.STANDARD,
                  location=l,
                  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='Test other odlc',
                  description_approved=False,
                  autonomous=True)
        t2.save()
        self.assertAlmostEqual(1.0, t1.similar_classifications_ratio(t2))

        # Test unequal standard odlcs.
        t1.alphanumeric = 'DEF'
        t1.alphanumeric_color = interop_api_pb2.Odlc.BLUE
        t1.save()
        self.assertAlmostEqual(3.0 / 5.0, t1.similar_classifications_ratio(t2))
        t1.shape = interop_api_pb2.Odlc.CIRCLE
        t1.shape_color = interop_api_pb2.Odlc.ORANGE
        t1.save()
        self.assertAlmostEqual(1.0 / 5.0, t1.similar_classifications_ratio(t2))

        # Test emergent type based on description approval.
        t1.odlc_type = interop_api_pb2.Odlc.EMERGENT
        t1.save()
        t2.odlc_type = interop_api_pb2.Odlc.EMERGENT
        t2.save()
        self.assertAlmostEqual(0.0, t1.similar_classifications_ratio(t2))
        t2.description_approved = True
        t2.save()
        self.assertAlmostEqual(1.0, t1.similar_classifications_ratio(t2))
예제 #4
0
    def test_creation_time(self):
        """Creation time is set on creation and doesn't change on update."""
        t = Odlc(mission=self.mission,
                 user=self.user,
                 odlc_type=interop_api_pb2.Odlc.STANDARD)
        t.save()

        orig = t.creation_time
        self.assertIsNotNone(orig)

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

        self.assertEqual(orig, t.creation_time)
예제 #5
0
    def test_last_modified_time(self):
        """Last modified time is set on creation and changes every update."""
        t = Odlc(mission=self.mission,
                 user=self.user,
                 odlc_type=interop_api_pb2.Odlc.STANDARD)
        t.save()

        orig = t.last_modified_time
        self.assertIsNotNone(orig)

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

        self.assertGreater(t.last_modified_time, orig)
예제 #6
0
    def test_interop_submission(self):
        """Tests interop_submission correctly filters submissions."""
        # t1 created and updated before mission time starts.
        t1 = Odlc(user=self.user, odlc_type=OdlcType.standard)
        t1.save()
        t1.alphanumeric = 'A'
        t1.save()

        # t2 created before mission time starts and updated once it does.
        t2 = Odlc(user=self.user, odlc_type=OdlcType.standard)
        t2.save()

        # Mission time starts.
        event = MissionClockEvent(
            user=self.user, team_on_clock=True, team_on_timeout=False)
        event.save()

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

        # t3 created and updated during mission time.
        t3 = Odlc(user=self.user, odlc_type=OdlcType.standard)
        t3.save()
        t3.alphanumeric = 'A'
        t3.save()

        # t4 created in in mission time and updated during timeout.
        t4 = Odlc(user=self.user, odlc_type=OdlcType.standard)
        t4.save()

        # Team takes timeout. Mission time stops.
        event = MissionClockEvent(
            user=self.user, team_on_clock=False, team_on_timeout=True)
        event.save()

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

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

        # t6 created and updated once mission time resumes.
        event = MissionClockEvent(
            user=self.user, team_on_clock=True, team_on_timeout=False)
        event.save()
        t6 = Odlc(user=self.user, odlc_type=OdlcType.standard)
        t6.save()
        t6.alphanumeric = 'A'
        t6.save()
        event = MissionClockEvent(
            user=self.user, team_on_clock=False, team_on_timeout=False)
        event.save()

        self.assertFalse(t1.interop_submission())
        self.assertFalse(t2.interop_submission())
        self.assertTrue(t3.interop_submission())
        self.assertFalse(t4.interop_submission())
        self.assertFalse(t5.interop_submission())
        self.assertTrue(t6.interop_submission())
예제 #7
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.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.save()

        # t3 created and updated in flight.
        t3 = Odlc(user=self.user, odlc_type=OdlcType.standard)
        t3.save()
        t3.alphanumeric = 'A'
        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.save()

        # t5 created and updated after landing.
        t5 = Odlc(user=self.user, odlc_type=OdlcType.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 = Odlc(user=self.user, odlc_type=OdlcType.standard)
        t6.save()
        t6.alphanumeric = 'A'
        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())
예제 #8
0
    def test_similar_classifications_ratio(self):
        """Tests similar classification ratios are computed correctly."""
        # Test equal standard odlcs.
        l = GpsPosition(latitude=38, longitude=-76)
        l.save()
        t1 = Odlc(
            user=self.user,
            odlc_type=OdlcType.standard,
            location=l,
            orientation=Orientation.s,
            shape=Shape.square,
            background_color=Color.white,
            alphanumeric='ABC',
            alphanumeric_color=Color.black,
            description='Test odlc',
            description_approved=True,
            autonomous=True)
        t1.save()
        t2 = Odlc(
            user=self.user,
            odlc_type=OdlcType.standard,
            location=l,
            orientation=Orientation.s,
            shape=Shape.square,
            background_color=Color.white,
            alphanumeric='ABC',
            alphanumeric_color=Color.black,
            description='Test other odlc',
            description_approved=False,
            autonomous=True)
        t2.save()
        self.assertAlmostEqual(1.0, t1.similar_classifications_ratio(t2))

        # Test unequal standard odlcs.
        t1.alphanumeric = 'DEF'
        t1.alphanumeric_color = Color.blue
        t1.save()
        self.assertAlmostEqual(3.0 / 5.0, t1.similar_classifications_ratio(t2))
        t1.shape = Shape.circle
        t1.background_color = Color.orange
        t1.save()
        self.assertAlmostEqual(1.0 / 5.0, t1.similar_classifications_ratio(t2))

        # Test different types.
        t1.odlc_type = OdlcType.off_axis
        t1.save()
        self.assertAlmostEqual(0, t1.similar_classifications_ratio(t2))

        # Test off_axis is same as standard.
        t2.odlc_type = OdlcType.off_axis
        t2.alphanumeric = 'DEF'
        t2.save()
        self.assertAlmostEqual(2.0 / 5.0, t1.similar_classifications_ratio(t2))

        # Test emergent type based on description approval.
        t1.odlc_type = OdlcType.emergent
        t1.save()
        t2.odlc_type = OdlcType.emergent
        t2.save()
        self.assertAlmostEqual(0.0, t1.similar_classifications_ratio(t2))
        t2.description_approved = True
        t2.save()
        self.assertAlmostEqual(1.0, t1.similar_classifications_ratio(t2))
예제 #9
0
    def test_similar_orientation(self):
        """Test similar orientations are computed correctly."""
        l = GpsPosition(latitude=38, longitude=-76)
        l.save()
        t1 = Odlc(user=self.user,
                  odlc_type=OdlcType.standard,
                  location=l,
                  orientation=Orientation.s,
                  shape=Shape.square,
                  background_color=Color.white,
                  alphanumeric='ABC',
                  alphanumeric_color=Color.black,
                  description='Test odlc',
                  description_approved=True,
                  autonomous=True)
        t1.save()
        t2 = Odlc(user=self.user,
                  odlc_type=OdlcType.standard,
                  location=l,
                  orientation=Orientation.s,
                  shape=Shape.square,
                  background_color=Color.white,
                  alphanumeric='ABC',
                  alphanumeric_color=Color.black,
                  description='Test other odlc',
                  description_approved=False,
                  autonomous=True)
        t2.save()

        # Requires exact same orientation.
        for alpha in ['A', 'a']:
            t1.alphanumeric = alpha
            t1.orientation = Orientation.s
            t2.orientation = Orientation.s
            self.assertTrue(t1.similar_orientation(t2))
            t2.orientation = Orientation.n
            self.assertFalse(t1.similar_orientation(t2))
            t2.orientation = Orientation.e
            self.assertFalse(t1.similar_orientation(t2))

        # Accepts rotation.
        for alpha in ['I', 'H', '8']:
            t1.alphanumeric = alpha
            t1.orientation = Orientation.s
            t2.orientation = Orientation.s
            self.assertTrue(t1.similar_orientation(t2))
            t2.orientation = Orientation.n
            self.assertTrue(t1.similar_orientation(t2))
            t2.orientation = Orientation.e
            self.assertFalse(t1.similar_orientation(t2))

        # Accepts any.
        for alpha in ['O', 'o', '0']:
            t1.alphanumeric = alpha
            t1.orientation = Orientation.s
            t2.orientation = Orientation.s
            self.assertTrue(t1.similar_orientation(t2))
            t2.orientation = Orientation.n
            self.assertTrue(t1.similar_orientation(t2))
            t2.orientation = Orientation.e
            self.assertTrue(t1.similar_orientation(t2))
예제 #10
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))
예제 #11
0
    def test_similar_orientation(self):
        """Test similar orientations are computed correctly."""
        l = GpsPosition(latitude=38, longitude=-76)
        l.save()
        t1 = Odlc(mission=self.mission,
                  user=self.user,
                  odlc_type=interop_api_pb2.Odlc.STANDARD,
                  location=l,
                  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='Test odlc',
                  description_approved=True,
                  autonomous=True)
        t1.save()
        t2 = Odlc(mission=self.mission,
                  user=self.user,
                  odlc_type=interop_api_pb2.Odlc.STANDARD,
                  location=l,
                  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='Test other odlc',
                  description_approved=False,
                  autonomous=True)
        t2.save()

        # Requires exact same orientation.
        for alpha in ['A', 'a']:
            t1.alphanumeric = alpha
            t1.orientation = interop_api_pb2.Odlc.S
            t2.orientation = interop_api_pb2.Odlc.S
            self.assertTrue(t1.similar_orientation(t2))
            t2.orientation = interop_api_pb2.Odlc.N
            self.assertFalse(t1.similar_orientation(t2))
            t2.orientation = interop_api_pb2.Odlc.E
            self.assertFalse(t1.similar_orientation(t2))

        # Accepts rotation.
        for alpha in ['I', 'H', '8']:
            t1.alphanumeric = alpha
            t1.orientation = interop_api_pb2.Odlc.S
            t2.orientation = interop_api_pb2.Odlc.S
            self.assertTrue(t1.similar_orientation(t2))
            t2.orientation = interop_api_pb2.Odlc.N
            self.assertTrue(t1.similar_orientation(t2))
            t2.orientation = interop_api_pb2.Odlc.E
            self.assertFalse(t1.similar_orientation(t2))

        # Accepts any.
        for alpha in ['O', 'o', '0']:
            t1.alphanumeric = alpha
            t1.orientation = interop_api_pb2.Odlc.S
            t2.orientation = interop_api_pb2.Odlc.S
            self.assertTrue(t1.similar_orientation(t2))
            t2.orientation = interop_api_pb2.Odlc.N
            self.assertTrue(t1.similar_orientation(t2))
            t2.orientation = interop_api_pb2.Odlc.E
            self.assertTrue(t1.similar_orientation(t2))