aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/tests/unit/network_services/libs
diff options
context:
space:
mode:
Diffstat (limited to 'yardstick/tests/unit/network_services/libs')
-rw-r--r--yardstick/tests/unit/network_services/libs/ixia_libs/test_IxNet.py24
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',