diff options
author | Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com> | 2018-05-08 07:02:00 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2018-05-08 07:02:00 +0000 |
commit | 5c57c5a51f9a492cdb05207ba37a765b425db40f (patch) | |
tree | 094abe8c417ad51e8a85c1fe6528123e78cbb006 /yardstick/tests | |
parent | d2c31b133a1429f3028d7f4c2969c1c5c52903a6 (diff) | |
parent | f9961e6c12b9b50c490a7d70ae1474ca1bd09f5e (diff) |
Merge "Add IxNetwork API Python Binding package"
Diffstat (limited to 'yardstick/tests')
-rw-r--r-- | yardstick/tests/unit/network_services/libs/ixia_libs/test_IxNet.py | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/yardstick/tests/unit/network_services/libs/ixia_libs/test_IxNet.py b/yardstick/tests/unit/network_services/libs/ixia_libs/test_IxNet.py index fe750e5ba..7ca2f0f19 100644 --- a/yardstick/tests/unit/network_services/libs/ixia_libs/test_IxNet.py +++ b/yardstick/tests/unit/network_services/libs/ixia_libs/test_IxNet.py @@ -13,8 +13,9 @@ # limitations under the License. # -import unittest import mock +import IxNetwork +import unittest from yardstick.network_services.libs.ixia_libs.IxNet.IxNet import IxNextgen from yardstick.network_services.libs.ixia_libs.IxNet.IxNet import IP_VERSION_4 @@ -30,15 +31,20 @@ class TestIxNextgen(unittest.TestCase): ixnet_gen = IxNextgen() self.assertIsNone(ixnet_gen._bidir) - @mock.patch("yardstick.network_services.libs.ixia_libs.IxNet.IxNet.sys") - def test_connect(self, *args): - + @mock.patch.object(IxNetwork, 'IxNet') + def test_connect(self, mock_ixnet): + ixnet_instance = mock.Mock() + mock_ixnet.return_value = ixnet_instance ixnet_gen = IxNextgen() - ixnet_gen.get_config = mock.MagicMock() - ixnet_gen.get_ixnet = mock.MagicMock() + with mock.patch.object(ixnet_gen, 'get_config') as mock_config: + mock_config.return_value = {'machine': 'machine_fake', + 'port': 'port_fake', + 'version': 12345} + ixnet_gen._connect(mock.ANY) - self.assertRaises(ImportError, ixnet_gen._connect, - {"py_lib_path": "/tmp"}) + ixnet_instance.connect.assert_called_once_with( + 'machine_fake', '-port', 'port_fake', '-version', '12345') + mock_config.assert_called_once() def test_clear_ixia_config(self): ixnet = mock.MagicMock() @@ -655,13 +661,11 @@ class TestIxNextgen(unittest.TestCase): "version": "test3", "ixchassis": "test4", "tcl_port": "test5", - "py_lib_path": "test6", }, } } expected = { - 'py_lib_path': 'test6', 'machine': 'test1', 'port': 'test5', 'chassis': 'test4', |