Merge "Replace assertEqual(x, True|False) with assert[True|False](x)"
[yardstick.git] / tests / unit / network_services / vnf_generic / vnf / test_sample_vnf.py
index b4306ce..af941c0 100644 (file)
@@ -704,8 +704,8 @@ class TestDpdkVnfSetupEnvHelper(unittest.TestCase):
 
         intf_0 = vnfd_helper.vdu[0]['external-interface'][0]['virtual-interface']
         intf_1 = vnfd_helper.vdu[0]['external-interface'][1]['virtual-interface']
-        self.assertEquals(0, intf_0['dpdk_port_num'])
-        self.assertEquals(1, intf_1['dpdk_port_num'])
+        self.assertEqual(0, intf_0['dpdk_port_num'])
+        self.assertEqual(1, intf_1['dpdk_port_num'])
 
     def test_tear_down(self):
         vnfd_helper = VnfdHelper(self.VNFD_0)
@@ -1879,6 +1879,23 @@ class TestSampleVnf(unittest.TestCase):
         self.assertRaises(y_exceptions.FunctionNotImplemented,
                           sample_vnf.scale)
 
+    def test__run(self):
+        test_cmd = 'test cmd'
+        run_kwargs = {'arg1': 'val1', 'arg2': 'val2'}
+        vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
+        sample_vnf = SampleVNF('vnf1', vnfd)
+        sample_vnf.ssh_helper = mock.Mock()
+        sample_vnf.setup_helper = mock.Mock()
+        with mock.patch.object(sample_vnf, '_build_config',
+                               return_value=test_cmd), \
+                mock.patch.object(sample_vnf, '_build_run_kwargs'):
+            sample_vnf.run_kwargs = run_kwargs
+            sample_vnf._run()
+        sample_vnf.ssh_helper.drop_connection.assert_called_once()
+        sample_vnf.ssh_helper.run.assert_called_once_with(test_cmd,
+                                                          **run_kwargs)
+        sample_vnf.setup_helper.kill_vnf.assert_called_once()
+
 
 class TestSampleVNFTrafficGen(unittest.TestCase):