Merge "Add host&targer in scenario['options']['server_name'] support"
[yardstick.git] / tests / unit / network_services / vnf_generic / vnf / test_base.py
index e4f4450..478ce18 100644 (file)
@@ -25,6 +25,7 @@ from multiprocessing import Queue
 
 from yardstick.network_services.vnf_generic.vnf.base import \
     QueueFileWrapper, GenericVNF, GenericTrafficGen
+from yardstick.ssh import SSH
 
 IP_PIPELINE_CFG_FILE_TPL = """
 arp_route_tbl = ({port0_local_ip_hex},{port0_netmask_hex},1,"""
@@ -48,9 +49,9 @@ class FileAbsPath(object):
         return file_path
 
 
-def mock_ssh(ssh, spec=None, exec_result=_LOCAL_OBJECT, run_result=_LOCAL_OBJECT):
+def mock_ssh(mock_ssh_type, spec=None, exec_result=_LOCAL_OBJECT, run_result=_LOCAL_OBJECT):
     if spec is None:
-        spec = ssh.SSH
+        spec = SSH
 
     if exec_result is _LOCAL_OBJECT:
         exec_result = 0, "", ""
@@ -58,10 +59,12 @@ def mock_ssh(ssh, spec=None, exec_result=_LOCAL_OBJECT, run_result=_LOCAL_OBJECT
     if run_result is _LOCAL_OBJECT:
         run_result = 0, "", ""
 
-    ssh_mock = mock.Mock(autospec=spec)
-    ssh_mock.execute = mock.Mock(return_value=exec_result)
-    ssh_mock.run = mock.Mock(return_value=run_result)
-    ssh.from_node.return_value = ssh_mock
+    mock_ssh_instance = mock.Mock(autospec=spec)
+    mock_ssh_instance._get_client.return_value = mock.Mock()
+    mock_ssh_instance.execute.return_value = exec_result
+    mock_ssh_instance.run.return_value = run_result
+    mock_ssh_type.from_node.return_value = mock_ssh_instance
+    return mock_ssh_instance
 
 
 class TestQueueFileWrapper(unittest.TestCase):
@@ -147,7 +150,7 @@ class TestGenericVNF(unittest.TestCase):
                             'local_ip': '152.16.100.19',
                             'type': 'PCI-PASSTHROUGH',
                             'netmask': '255.255.255.0',
-                            'dpdk_port_num': '0',
+                            'dpdk_port_num': 0,
                             'bandwidth': '10 Gbps',
                             'dst_ip': '152.16.100.20',
                             'local_mac': '00:00:00:00:00:01'
@@ -162,7 +165,7 @@ class TestGenericVNF(unittest.TestCase):
                             'local_ip': '152.16.40.19',
                             'type': 'PCI-PASSTHROUGH',
                             'netmask': '255.255.255.0',
-                            'dpdk_port_num': '1',
+                            'dpdk_port_num': 1,
                             'bandwidth': '10 Gbps',
                             'dst_ip': '152.16.40.20',
                             'local_mac': '00:00:00:00:00:02'