def step_impl(context, destination, device): route = Route(destination, device) route.refresh() assert not route.is_reachable() response = None try: response = os.system('ping -c 1 %s 2>/dev/null' % destination.split('/')[0]) except: assert response == 2 assert response is not None
def test_refresh_route(self, execute_command): execute_command.return_value = self.ip_route_list_output route = Route('default', 'wlo1') route.refresh() execute_command.assert_called_once_with("ip route list", namespace=None) self.assertEqual(route.metric, '600') self.assertEqual(route.gateway, '192.168.0.254') self.assertIsNone(route.source) self.assertIsNone(route.scope) self.assertIsNone(route.namespace)
def test_refresh_non_existing_route(self, execute_command): execute_command.return_value = self.ip_route_list_output route = Route('destination', 'device') with self.assertRaises(ObjectNotFoundException): route.refresh() execute_command.assert_called_once_with("ip route list", namespace=None)