def test_check_add_route_exception(self): try: add_route() except Exception as err: self.assertEqual( err.args[0], "device argument is mandatory")
def test_check_add_route_network_exception(self): try: add_route( device=self.mocked_obj, network="5.0.0.0") except Exception as err: self.assertEqual( err.args[0], "network,netmask and gateway are required for network based route")
def test_check_add_route_host_exception(self): try: add_route( device=self.mocked_obj, host="10.209.95.254") except Exception as err: self.assertEqual( err.args[0], "Gateway address is required for host based route")
def test_check_add_route_ipv6_default_gateway_fail(self): lst = [Response(""),Response("*/0 2006::2")] get_ip_address_type=MagicMock(side_effect="ipv6") self.mocked_obj.shell = MagicMock(side_effect=lst) try: add_route( device=self.mocked_obj, default_gateway="2006::1") except Exception as err: self.assertEqual( err.args[0], "Route is not configured")
def test_check_add_route_ipv4_default_gateway_fail(self): lst = [Response(""),Response("0.0.0.0 10.219.95.254 0.0.0.0 UG 0 0 0 eth0")] get_ip_address_type=MagicMock(side_effect="ipv4") self.mocked_obj.shell = MagicMock(side_effect=lst) try: add_route( device=self.mocked_obj, default_gateway="10.209.95.254") except Exception as err: self.assertEqual( err.args[0], "Route is not configured")
def test_check_add_route_ipv6_network_fail(self): lst = [Response(""),Response("2005::/64 2004::254")] get_ip_address_type=MagicMock(side_effect="ipv6") self.mocked_obj.shell = MagicMock(side_effect=lst) try: add_route( device=self.mocked_obj, network="2005::", gateway="2001::25", netmask="64") except Exception as err: self.assertEqual( err.args[0], "Route is not configured")
def test_check_add_route_ipv4_network_fail(self): lst = [Response(""),Response("5.0.0.0 4.0.0.254 255.0.0.0 UG 0 0 0 eth0")] get_ip_address_type=MagicMock(side_effect="ipv4") self.mocked_obj.shell = MagicMock(side_effect=lst) try: add_route( device=self.mocked_obj, network="5.0.0.0", gateway="6.0.0.254", netmask="255.0.0.0") except Exception as err: self.assertEqual( err.args[0], "Route is not configured")
def test_check_add_route_ipv6_default_gateway_success(self): lst = [Response(""),Response("*/0 2006::1")] get_ip_address_type=MagicMock(side_effect="ipv6") self.mocked_obj.shell = MagicMock(side_effect=lst) self.assertEqual( add_route( device=self.mocked_obj, default_gateway="2006::1"), True)
def test_check_add_route_ipv4_default_gateway_success(self): lst = [Response(""),Response("0.0.0.0 10.209.95.254 0.0.0.0 UG 0 0 0 eth0")] get_ip_address_type=MagicMock(side_effect="ipv4") self.mocked_obj.shell = MagicMock(side_effect=lst) self.assertEqual( add_route( device=self.mocked_obj, default_gateway="10.209.95.254"), True)
def test_check_add_route_ipv6_host_success(self): lst = [Response(""),Response("2005::1/128 2005::254 \n")] get_ip_address_type=MagicMock(side_effect="ipv6") self.mocked_obj.shell = MagicMock(side_effect=lst) self.assertEqual( add_route( device=self.mocked_obj, host="2005::1", gateway="2005::254"), True)
def test_check_add_route_ipv4_host_success(self): lst = [Response(""),Response("5.0.0.1 4.0.0.254 255.255.255.255 UG 0 0 0 eth0")] get_ip_address_type=MagicMock(side_effect="ipv4") self.mocked_obj.shell = MagicMock(side_effect=lst) self.assertEqual( add_route( device=self.mocked_obj, host="5.0.0.1", gateway="4.0.0.254"), True)
def test_check_add_route_ipv6_network_success(self): lst = [Response(""),Response("2005::/64 2004::254 ")] get_ip_address_type=MagicMock(side_effect="ipv6") self.mocked_obj.shell = MagicMock(side_effect=lst) self.assertEqual( add_route( device=self.mocked_obj, network="2005::", gateway="2004::254", netmask="64"), True)
def test_check_add_route_with_interface(self): lst = [Response(""),Response("5.0.0.0 4.0.0.254 255.0.0.0 UG 0 0 0 eth0")] get_ip_address_type=MagicMock(side_effect="ipv4") self.mocked_obj.shell = MagicMock(side_effect=lst) self.assertEqual( add_route( device=self.mocked_obj, network="5.0.0.0", gateway="4.0.0.254", netmask="255.0.0.0", interface="eth0"), True)