def test_remove(self): """ Check that there is no trace of the vehicle ID of the vehicle meant to be removed in the vehicles class. """ # generate a vehicles class vehicles = VehicleParams() vehicles.add("test", num_vehicles=10) vehicles.add("test_rl", num_vehicles=10, acceleration_controller=(RLController, {})) # remove one human-driven vehicle and on rl vehicle vehicles.remove("test_0") vehicles.remove("test_rl_0") # ensure that the removed vehicle's ID is not in any lists of vehicles self.assertTrue("test_0" not in vehicles.get_ids(), msg="vehicle still in get_ids()") self.assertTrue("test_0" not in vehicles.get_human_ids(), msg="vehicle still in get_controlled_lc_ids()") self.assertTrue("test_0" not in vehicles.get_controlled_lc_ids(), msg="vehicle still in get_controlled_lc_ids()") self.assertTrue("test_0" not in vehicles.get_controlled_ids(), msg="vehicle still in get_controlled_ids()") self.assertTrue("test_rl_0" not in vehicles.get_ids(), msg="RL vehicle still in get_ids()") self.assertTrue("test_rl_0" not in vehicles.get_rl_ids(), msg="RL vehicle still in get_rl_ids()") # ensure that the vehicles are not storing extra information in the # vehicles.__vehicles dict error_state = vehicles.get_state('test_0', "type", error=None) self.assertIsNone(error_state) error_state_rl = vehicles.get_state('rl_test_0', "type", error=None) self.assertIsNone(error_state_rl) # ensure that the num_vehicles matches the actual number of vehicles self.assertEqual(vehicles.num_vehicles, len(vehicles.get_ids())) # ensures that then num_rl_vehicles matches the actual number of rl veh self.assertEqual(vehicles.num_rl_vehicles, len(vehicles.get_rl_ids()))