From 67bd29933789e7f31c52290fdd43835e54f89eaf Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Thu, 23 Nov 2017 09:08:14 +0000 Subject: Make GenericVNF an abstract class GenericVNF class is now an abstract class. Only optional methods are implemented. Mandatory methods: - instantiate - wait_for_instantiate - terminate - scale - collect_kpi. JIRA: YARDSTICK-866 Change-Id: Ia8766f9f98816e11894d1e72b0f3bd573d091d99 Signed-off-by: Rodolfo Alonso Hernandez --- .../vnf_generic/vnf/test_prox_vnf.py | 34 +++++++--------------- 1 file changed, 11 insertions(+), 23 deletions(-) (limited to 'tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py') diff --git a/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py index e29e8ddcd..ee6c67eb7 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py @@ -15,8 +15,6 @@ # limitations under the License. # -from __future__ import absolute_import - import errno import os import unittest @@ -316,13 +314,13 @@ class TestProxApproxVnf(unittest.TestCase): } @mock.patch(SSH_HELPER) - def test___init__(self, ssh, mock_time): + def test___init__(self, ssh, *args): mock_ssh(ssh) prox_approx_vnf = ProxApproxVnf(NAME, self.VNFD0) self.assertIsNone(prox_approx_vnf._vnf_process) @mock.patch(SSH_HELPER) - def test_collect_kpi_no_client(self, ssh, mock_time): + def test_collect_kpi_no_client(self, ssh, *args): mock_ssh(ssh) prox_approx_vnf = ProxApproxVnf(NAME, self.VNFD0) @@ -337,7 +335,7 @@ class TestProxApproxVnf(unittest.TestCase): self.assertEqual(result, expected) @mock.patch(SSH_HELPER) - def test_collect_kpi(self, ssh, mock_time): + def test_collect_kpi(self, ssh, *args): mock_ssh(ssh) resource_helper = mock.MagicMock() @@ -357,7 +355,7 @@ class TestProxApproxVnf(unittest.TestCase): self.assertEqual(result, expected) @mock.patch(SSH_HELPER) - def test_collect_kpi_error(self, ssh, mock_time): + def test_collect_kpi_error(self, ssh, *args): mock_ssh(ssh) resource_helper = mock.MagicMock() @@ -370,7 +368,7 @@ class TestProxApproxVnf(unittest.TestCase): with self.assertRaises(RuntimeError): prox_approx_vnf.collect_kpi() - def _get_file_abspath(self, filename, mock_time): + def _get_file_abspath(self, filename, *args): curr_path = os.path.dirname(os.path.abspath(__file__)) file_path = os.path.join(curr_path, filename) return file_path @@ -378,7 +376,7 @@ class TestProxApproxVnf(unittest.TestCase): @mock.patch('yardstick.benchmark.scenarios.networking.vnf_generic.open', create=True) @mock.patch('yardstick.network_services.helpers.iniparser.open', create=True) @mock.patch(SSH_HELPER) - def test_run_prox(self, ssh, *_): + def test_run_prox(self, ssh, *args): mock_ssh(ssh) prox_approx_vnf = ProxApproxVnf(NAME, self.VNFD0) @@ -394,7 +392,7 @@ class TestProxApproxVnf(unittest.TestCase): self.assertEqual(result, expected) @mock.patch(SSH_HELPER) - def bad_test_instantiate(self, ssh, mock_time): + def bad_test_instantiate(self, *args): prox_approx_vnf = ProxApproxVnf(NAME, self.VNFD0) prox_approx_vnf.scenario_helper = mock.MagicMock() prox_approx_vnf.setup_helper = mock.MagicMock() @@ -403,7 +401,7 @@ class TestProxApproxVnf(unittest.TestCase): prox_approx_vnf.setup_helper.build_config.assert_called_once() @mock.patch(SSH_HELPER) - def test_wait_for_instantiate_panic(self, ssh, mock_time): + def test_wait_for_instantiate_panic(self, ssh, *args): mock_ssh(ssh, exec_result=(1, "", "")) prox_approx_vnf = ProxApproxVnf(NAME, self.VNFD0) prox_approx_vnf._vnf_process = mock.MagicMock(**{"is_alive.return_value": True}) @@ -413,16 +411,9 @@ class TestProxApproxVnf(unittest.TestCase): with self.assertRaises(RuntimeError): prox_approx_vnf.wait_for_instantiate() - @mock.patch(SSH_HELPER) - def test_scale(self, ssh, mock_time): - mock_ssh(ssh) - prox_approx_vnf = ProxApproxVnf(NAME, self.VNFD0) - with self.assertRaises(NotImplementedError): - prox_approx_vnf.scale() - @mock.patch('yardstick.network_services.vnf_generic.vnf.prox_helpers.socket') @mock.patch(SSH_HELPER) - def test_terminate(self, ssh, mock_socket, mock_time): + def test_terminate(self, ssh, *args): mock_ssh(ssh) prox_approx_vnf = ProxApproxVnf(NAME, self.VNFD0) prox_approx_vnf._vnf_process = mock.MagicMock() @@ -434,7 +425,7 @@ class TestProxApproxVnf(unittest.TestCase): self.assertIsNone(prox_approx_vnf.terminate()) @mock.patch(SSH_HELPER) - def test__vnf_up_post(self, ssh, mock_time): + def test__vnf_up_post(self, ssh, *args): mock_ssh(ssh) prox_approx_vnf = ProxApproxVnf(NAME, self.VNFD0) prox_approx_vnf.resource_helper = resource_helper = mock.Mock() @@ -443,7 +434,7 @@ class TestProxApproxVnf(unittest.TestCase): self.assertEqual(resource_helper.up_post.call_count, 1) @mock.patch(SSH_HELPER) - def test_vnf_execute_oserror(self, ssh, mock_time): + def test_vnf_execute_oserror(self, ssh, *args): mock_ssh(ssh) prox_approx_vnf = ProxApproxVnf(NAME, self.VNFD0) prox_approx_vnf.resource_helper = resource_helper = mock.Mock() @@ -457,6 +448,3 @@ class TestProxApproxVnf(unittest.TestCase): resource_helper.execute.side_effect = OSError(errno.EADDRINUSE, "") with self.assertRaises(OSError): prox_approx_vnf.vnf_execute("", _ignore_errors=True) - -if __name__ == '__main__': - unittest.main() -- cgit 1.2.3-korg