示例#1
0
 def test_get_waypoint_travel_time(self):
     """Tests travel time calc."""
     test_spds = [1, 10, 100, 500]
     for (lon2, lat2, lon1, lat1, dist_km) in TESTDATA_COMPETITION_DIST:
         dist_ft = units.kilometers_to_feet(dist_km)
         for speed in test_spds:
             speed_fps = units.knots_to_feet_per_second(speed)
             time = dist_ft / speed_fps
             gpos1 = GpsPosition()
             gpos1.latitude = lat1
             gpos1.longitude = lon1
             gpos1.save()
             apos1 = AerialPosition()
             apos1.gps_position = gpos1
             apos1.altitude_msl = 0
             apos1.save()
             wpt1 = Waypoint()
             wpt1.position = apos1
             gpos2 = GpsPosition()
             gpos2.latitude = lat2
             gpos2.longitude = lon2
             gpos2.save()
             apos2 = AerialPosition()
             apos2.gps_position = gpos2
             apos2.altitude_msl = 0
             apos2.save()
             wpt2 = Waypoint()
             wpt2.position = apos2
             waypoints = [wpt1, wpt2]
             obstacle = MovingObstacle()
             obstacle.speed_avg = speed
             self.assertTrue(
                 self.eval_travel_time(
                     obstacle.get_waypoint_travel_time(waypoints, 0, 1),
                     time))
示例#2
0
 def test_get_waypoint_travel_time(self):
     """Tests travel time calc."""
     test_spds = [1, 10, 100, 500]
     for (lon2, lat2, lon1, lat1, dist_km) in TESTDATA_COMPETITION_DIST:
         dist_ft = units.kilometers_to_feet(dist_km)
         for speed in test_spds:
             speed_fps = units.knots_to_feet_per_second(speed)
             time = dist_ft / speed_fps
             gpos1 = GpsPosition()
             gpos1.latitude = lat1
             gpos1.longitude = lon1
             gpos1.save()
             apos1 = AerialPosition()
             apos1.gps_position = gpos1
             apos1.altitude_msl = 0
             apos1.save()
             wpt1 = Waypoint()
             wpt1.position = apos1
             gpos2 = GpsPosition()
             gpos2.latitude = lat2
             gpos2.longitude = lon2
             gpos2.save()
             apos2 = AerialPosition()
             apos2.gps_position = gpos2
             apos2.altitude_msl = 0
             apos2.save()
             wpt2 = Waypoint()
             wpt2.position = apos2
             waypoints = [wpt1, wpt2]
             obstacle = MovingObstacle()
             obstacle.speed_avg = speed
             self.assertTrue(self.eval_travel_time(
                 obstacle.get_waypoint_travel_time(waypoints, 0, 1), time))
示例#3
0
    def test_get_waypoint_travel_time_invalid_inputs(self):
        """Tests proper invalid input handling."""
        obstacle = MovingObstacle()
        obstacle.speed_avg = 1

        self.assertIsNone(obstacle.get_waypoint_travel_time(None, 1, 1))
        self.assertIsNone(obstacle.get_waypoint_travel_time([], 1, 1))
        self.assertIsNone(obstacle.get_waypoint_travel_time([None], 1, 1))
        self.assertIsNone(
            obstacle.get_waypoint_travel_time([None, None], None, 1))
        self.assertIsNone(
            obstacle.get_waypoint_travel_time([None, None], 1, None))
        self.assertIsNone(
            obstacle.get_waypoint_travel_time([None, None], -1, 0))
        self.assertIsNone(
            obstacle.get_waypoint_travel_time([None, None], 0, -1))
        self.assertIsNone(obstacle.get_waypoint_travel_time([None, None], 2,
                                                            0))
        self.assertIsNone(obstacle.get_waypoint_travel_time([None, None], 0,
                                                            2))
        obstacle.speed_avg = 0
        self.assertIsNone(obstacle.get_waypoint_travel_time([None, None], 0,
                                                            1))
示例#4
0
    def test_get_waypoint_travel_time_invalid_inputs(self):
        """Tests proper invalid input handling."""
        obstacle = MovingObstacle()
        obstacle.speed_avg = 1

        self.assertIsNone(obstacle.get_waypoint_travel_time(None, 1, 1))
        self.assertIsNone(obstacle.get_waypoint_travel_time([], 1, 1))
        self.assertIsNone(obstacle.get_waypoint_travel_time([None], 1, 1))
        self.assertIsNone(obstacle.get_waypoint_travel_time(
            [None, None], None, 1))
        self.assertIsNone(obstacle.get_waypoint_travel_time(
            [None, None], 1, None))
        self.assertIsNone(obstacle.get_waypoint_travel_time(
            [None, None], -1, 0))
        self.assertIsNone(obstacle.get_waypoint_travel_time(
            [None, None], 0, -1))
        self.assertIsNone(obstacle.get_waypoint_travel_time(
            [None, None], 2, 0))
        self.assertIsNone(obstacle.get_waypoint_travel_time(
            [None, None], 0, 2))
        obstacle.speed_avg = 0
        self.assertIsNone(obstacle.get_waypoint_travel_time(
            [None, None], 0, 1))