def setUp(self): """Populates an active mission to test a cached view.""" pos = GpsPosition() pos.latitude = 10 pos.longitude = 10 pos.save() self.pos = pos obst = StationaryObstacle() obst.gps_position = pos obst.cylinder_radius = 10 obst.cylinder_height = 10 obst.save() self.obst = obst config = MissionConfig() config.is_active = True config.home_pos = pos config.emergent_last_known_pos = pos config.off_axis_target_pos = pos config.sric_pos = pos config.air_drop_pos = pos config.save() self.config = config config.stationary_obstacles.add(obst) config.save() self.login_url = reverse('auvsi_suas:login') self.obst_url = reverse('auvsi_suas:obstacles') self.clear_cache_url = reverse('auvsi_suas:clear_cache')
def setUp(self): """Sets up the client, obstacle URL, obstacles, and user.""" # Setup user self.user = User.objects.create_user('testuser', '*****@*****.**', 'testpass') self.user.save() # Setup the obstacles for path in TESTDATA_MOVOBST_PATHS: # Stationary obstacle (stat_lat, stat_lon, _) = path[0] stat_gps = GpsPosition() stat_gps.latitude = stat_lat stat_gps.longitude = stat_lon stat_gps.save() stat_obst = StationaryObstacle() stat_obst.gps_position = stat_gps stat_obst.cylinder_radius = 100 stat_obst.cylinder_height = 200 stat_obst.save() # Moving obstacle mov_obst = MovingObstacle() mov_obst.speed_avg = 40 mov_obst.sphere_radius = 100 mov_obst.save() for pt_id in range(len(path)): # Obstacle waypoints (wpt_lat, wpt_lon, wpt_alt) = path[pt_id] gpos = GpsPosition() gpos.latitude = wpt_lat gpos.longitude = wpt_lon gpos.save() apos = AerialPosition() apos.altitude_msl = wpt_alt apos.gps_position = gpos apos.save() wpt = Waypoint() wpt.name = 'test waypoint' wpt.order = pt_id wpt.position = apos wpt.save() mov_obst.waypoints.add(wpt) mov_obst.save() # Setup test objs self.client = Client() self.loginUrl = reverse('auvsi_suas:login') self.obstUrl = reverse('auvsi_suas:obstacles')
def setUp(self): """Sets up the client, obstacle URL, obstacles, and user.""" # Setup user self.user = User.objects.create_user( 'testuser', '*****@*****.**', 'testpass') self.user.save() # Setup the obstacles for path in TESTDATA_MOVOBST_PATHS: # Stationary obstacle (stat_lat, stat_lon, _) = path[0] stat_gps = GpsPosition() stat_gps.latitude = stat_lat stat_gps.longitude = stat_lon stat_gps.save() stat_obst = StationaryObstacle() stat_obst.gps_position = stat_gps stat_obst.cylinder_radius = 100 stat_obst.cylinder_height = 200 stat_obst.save() # Moving obstacle mov_obst = MovingObstacle() mov_obst.speed_avg = 40 mov_obst.sphere_radius = 100 mov_obst.save() for pt_id in range(len(path)): # Obstacle waypoints (wpt_lat, wpt_lon, wpt_alt) = path[pt_id] gpos = GpsPosition() gpos.latitude = wpt_lat gpos.longitude = wpt_lon gpos.save() apos = AerialPosition() apos.altitude_msl = wpt_alt apos.gps_position = gpos apos.save() wpt = Waypoint() wpt.name = 'test waypoint' wpt.order = pt_id wpt.position = apos wpt.save() mov_obst.waypoints.add(wpt) mov_obst.save() # Setup test objs self.client = Client() self.loginUrl = reverse('auvsi_suas:login') self.obstUrl = reverse('auvsi_suas:obstacles')
def setUp(self): """Populates an active mission to test a cached view.""" pos = GpsPosition() pos.latitude = 10 pos.longitude = 10 pos.save() self.pos = pos info = ServerInfo() info.timestamp = datetime.datetime.now() info.message = "Hello World" info.save() obst = StationaryObstacle() obst.gps_position = pos obst.cylinder_radius = 10 obst.cylinder_height = 10 obst.save() self.obst = obst config = MissionConfig() config.is_active = True config.home_pos = pos config.emergent_last_known_pos = pos config.off_axis_target_pos = pos config.sric_pos = pos config.ir_primary_target_pos = pos config.ir_secondary_target_pos = pos config.air_drop_pos = pos config.server_info = info config.save() self.config = config config.stationary_obstacles.add(obst) config.save() self.login_url = reverse('auvsi_suas:login') self.obst_url = reverse('auvsi_suas:obstacles') self.clear_cache_url = reverse('auvsi_suas:clear_cache')
def test_toJSON(self): """Tests the JSON serialization model.""" TEST_LAT = 100.10 TEST_LONG = 200.20 TEST_RADIUS = 150.50 TEST_HEIGHT = 75.30 gps_position = GpsPosition() gps_position.latitude = TEST_LAT gps_position.longitude = TEST_LONG obstacle = StationaryObstacle() obstacle.gps_position = gps_position obstacle.cylinder_radius = TEST_RADIUS obstacle.cylinder_height = TEST_HEIGHT json_data = obstacle.toJSON() self.assertTrue('latitude' in json_data) self.assertEqual(json_data['latitude'], TEST_LAT) self.assertTrue('longitude' in json_data) self.assertEqual(json_data['longitude'], TEST_LONG) self.assertTrue('cylinder_radius' in json_data) self.assertEqual(json_data['cylinder_radius'], TEST_RADIUS) self.assertTrue('cylinder_height' in json_data) self.assertEqual(json_data['cylinder_height'], TEST_HEIGHT)
def test_toJSON(self): """Tests the JSON serialization model.""" TEST_LAT = 100.10 TEST_LONG = 200.20 TEST_RADIUS = 150.50 TEST_HEIGHT = 75.30 gps_position = GpsPosition() gps_position.latitude = TEST_LAT gps_position.longitude = TEST_LONG obstacle = StationaryObstacle() obstacle.gps_position = gps_position obstacle.cylinder_radius = TEST_RADIUS obstacle.cylinder_height = TEST_HEIGHT json_data = obstacle.toJSON() self.assertTrue('latitude' in json_data) self.assertEqual(json_data['latitude'], TEST_LAT) self.assertTrue('longitude' in json_data) self.assertEqual(json_data['longitude'], TEST_LONG) self.assertTrue('cylinder_radius' in json_data) self.assertEqual(json_data['cylinder_radius'], TEST_RADIUS) self.assertTrue('cylinder_height' in json_data) self.assertEqual(json_data['cylinder_height'], TEST_HEIGHT)