Esempio n. 1
0
 def test_run_iproute_neigh_error(self):
     with mock.patch.object(pyroute2, "IPRoute") as iproute_mock:
         iproute_mock.side_effect = OSError(
             errno.EINVAL, "Test invalid argument exception")
         try:
             priv_lib._run_iproute_neigh(
                 "test_cmd", "eth0", None, test_param="test_value")
             self.fail("OSError exception not raised")
         except OSError as e:
             self.assertEqual(errno.EINVAL, e.errno)
Esempio n. 2
0
 def _test_run_iproute_neigh(self, namespace=None):
     ip_obj = "NetNS" if namespace else "IPRoute"
     with mock.patch.object(pyroute2, ip_obj) as ip_mock_cls:
         ip_mock = ip_mock_cls()
         ip_mock.__enter__().link_lookup.return_value = [2]
         priv_lib._run_iproute_neigh("test_cmd", "eth0", namespace,
                                     test_param="test_value")
         ip_mock.assert_has_calls([
             mock.call.__enter__().link_lookup(ifname="eth0"),
             mock.call.__exit__(None, None, None),
             mock.call.__enter__().neigh("test_cmd", ifindex=2,
                                         test_param="test_value")])
Esempio n. 3
0
 def test_run_iproute_neigh_error(self):
     with mock.patch.object(pyroute2, "IPRoute") as iproute_mock:
         iproute_mock.side_effect = OSError(
             errno.EINVAL, "Test invalid argument exception")
         try:
             priv_lib._run_iproute_neigh("test_cmd",
                                         "eth0",
                                         None,
                                         test_param="test_value")
             self.fail("OSError exception not raised")
         except OSError as e:
             self.assertEqual(errno.EINVAL, e.errno)
Esempio n. 4
0
 def _test_run_iproute_neigh(self, namespace=None):
     ip_obj = "NetNS" if namespace else "IPRoute"
     with mock.patch.object(pyroute2, ip_obj) as ip_mock_cls:
         ip_mock = ip_mock_cls()
         ip_mock.__enter__().link_lookup.return_value = [2]
         priv_lib._run_iproute_neigh("test_cmd",
                                     "eth0",
                                     namespace,
                                     test_param="test_value")
         ip_mock.assert_has_calls([
             mock.call.__enter__().link_lookup(ifname="eth0"),
             mock.call.__enter__().neigh("test_cmd",
                                         ifindex=2,
                                         test_param="test_value")
         ])