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 test_delete_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' with self.assertRaises(ObjectNotFoundException): route.delete() execute_command.assert_called_with('ip route del 1.2.3.4', namespace=None)
def test_route_discovery(self, destination, device, scope, source, metric, gateway, default, prohibit, reachable, execute_command): execute_command.return_value = self.ip_route_list_output route = Route(destination, device) route.scope = scope route.source = source route.gateway = gateway route.metric = metric routes = Route.discover() self.assertEqual(len(routes), 6) found_route = routes[routes.index(route)] self.assertTrue(self.deep_equality(route, found_route)) self.assertEqual(found_route.is_default(), default) self.assertEqual(found_route.is_prohibited(), prohibit) self.assertEqual(found_route.is_reachable(), reachable)
def test_delete_existing_route(self, execute_command): execute_command.return_value = self.ip_route_list_output route = Route('default', 'wlo1') route.gateway = '192.168.0.254' route.delete() execute_command.assert_called_with('ip route del default', namespace=None)
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)
def test_contains_route(self, execute_command): execute_command.return_value = self.ip_route_list_output route = Route('default', 'wlo1') route.gateway = '192.168.0.254' self.assertTrue(route.exists()) execute_command.assert_called_once_with('ip route list', namespace=None)