def test_add_existing_route(self, execute_command): execute_command.return_value = self.ip_route_list_output route = Route('default', 'wlo1') route.gateway = '192.168.0.254' with self.assertRaises(ObjectAlreadyExistsException): route.create() execute_command.assert_called_once_with('ip route list', namespace=None)
def step_impl(context, destination, device): route = Route(destination, device) if route not in Route.discover(): route.create()
def step_impl(context, destination, device): route = Route(destination, device) try: route.create() except Exception as e: context.exception = e
def test_add_non_existing_route(self, execute_command): execute_command.return_value = self.ip_route_list_output route = Route('1.2.3.4', 'wlo1') route.gateway = '192.168.0.254' route.create() execute_command.assert_called_with('ip route add 1.2.3.4 dev wlo1 via 192.168.0.254', namespace=None)