From e78f9daab290c9afa5f170fd204fb02fbbcbb393 Mon Sep 17 00:00:00 2001 From: nsubiron Date: Tue, 19 Mar 2019 19:27:08 +0100 Subject: [PATCH] Add smoke tests for checking the waypoints of each town --- PythonAPI/test/smoke/test_client.py | 13 -------- PythonAPI/test/smoke/test_map.py | 49 +++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 13 deletions(-) create mode 100644 PythonAPI/test/smoke/test_map.py diff --git a/PythonAPI/test/smoke/test_client.py b/PythonAPI/test/smoke/test_client.py index 0dfcdfcbc..ce6f77e60 100644 --- a/PythonAPI/test/smoke/test_client.py +++ b/PythonAPI/test/smoke/test_client.py @@ -4,7 +4,6 @@ # This work is licensed under the terms of the MIT license. # For a copy, see . -import random from . import SmokeTest @@ -12,15 +11,3 @@ from . import SmokeTest class TestClient(SmokeTest): def test_version(self): self.assertEqual(self.client.get_client_version(), self.client.get_server_version()) - - def test_reload_world(self): - map_name = self.client.get_world().get_map().name - world = self.client.reload_world() - self.assertEqual(map_name, world.get_map().name) - - def test_load_all_maps(self): - map_names = list(self.client.get_available_maps()) - random.shuffle(map_names) - for map_name in map_names: - world = self.client.load_world(map_name) - self.assertEqual(map_name.split('/')[-1], world.get_map().name) diff --git a/PythonAPI/test/smoke/test_map.py b/PythonAPI/test/smoke/test_map.py new file mode 100644 index 000000000..c5548cb3a --- /dev/null +++ b/PythonAPI/test/smoke/test_map.py @@ -0,0 +1,49 @@ +# Copyright (c) 2019 Computer Vision Center (CVC) at the Universitat Autonoma de +# Barcelona (UAB). +# +# This work is licensed under the terms of the MIT license. +# For a copy, see . + +import carla +import random + +from . import SmokeTest + + +class TestMap(SmokeTest): + def test_reload_world(self): + map_name = self.client.get_world().get_map().name + world = self.client.reload_world() + self.assertEqual(map_name, world.get_map().name) + + def test_load_all_maps(self): + map_names = list(self.client.get_available_maps()) + random.shuffle(map_names) + for map_name in map_names: + if map_name != '/Game/Carla/Maps/BaseMap/BaseMap': + print(map_name) + world = self.client.load_world(map_name) + m = world.get_map() + self.assertEqual(map_name.split('/')[-1], m.name) + self._check_map(m) + + def _check_map(self, m): + for spawn_point in m.get_spawn_points(): + waypoint = m.get_waypoint(spawn_point.location, project_to_road=False) + self.assertIsNotNone(waypoint) + topology = m.get_topology() + self.assertGreater(len(topology), 0) + waypoints = list(m.generate_waypoints(2)) + self.assertGreater(len(waypoints), 0) + random.shuffle(waypoints) + for waypoint in waypoints[:200]: + for _ in range(0, 20): + self.assertGreaterEqual(waypoint.lane_width, 0.0) + _ = waypoint.get_right_lane() + _ = waypoint.get_left_lane() + next_waypoints = waypoint.next(4) + if not next_waypoints: + break + waypoint = random.choice(next_waypoints) + _ = m.transform_to_geolocation(carla.Location()) + self.assertTrue(str(m.to_opendrive()))