From 9ef0bcbeb22ca70ff2ceb750c08fb24e46a9d0ea Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Fri, 22 Jun 2018 14:35:53 +0200 Subject: Update tempest to inherit from VmReady1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It also copies tempest.conf due to side effects raised by Barbican plugins. Change-Id: Ie87680f5d2e68527a5a61aac302838afc339dde8 Signed-off-by: Cédric Ollivier --- .../unit/openstack/tempest/test_conf_utils.py | 29 ---------------------- .../tests/unit/openstack/tempest/test_tempest.py | 25 ++++++------------- 2 files changed, 8 insertions(+), 46 deletions(-) (limited to 'functest/tests/unit/openstack/tempest') diff --git a/functest/tests/unit/openstack/tempest/test_conf_utils.py b/functest/tests/unit/openstack/tempest/test_conf_utils.py index 6f44337c9..1585cac09 100644 --- a/functest/tests/unit/openstack/tempest/test_conf_utils.py +++ b/functest/tests/unit/openstack/tempest/test_conf_utils.py @@ -14,41 +14,12 @@ import unittest import mock from functest.opnfv_tests.openstack.tempest import conf_utils -from functest.opnfv_tests.openstack.tempest import tempest from functest.utils import config class OSTempestConfUtilsTesting(unittest.TestCase): # pylint: disable=too-many-public-methods - @mock.Mock('os_client_config.make_shade') - def test_create_res_missing_net_dic(self, *mock_args): - # pylint: disable=unused-argument - tempest_resources = tempest.TempestResourcesManager() - with self.assertRaises(Exception) as context: - tempest_resources.create() - msg = 'Failed to create private network' - self.assertTrue(msg in context.exception) - - @mock.Mock('os_client_config.make_shade') - def test_create_res_missing_image(self, *mock_args): - # pylint: disable=unused-argument - tempest_resources = tempest.TempestResourcesManager() - - with self.assertRaises(Exception) as context: - tempest_resources.create() - msg = 'Failed to create image' - self.assertTrue(msg in context.exception, msg=str(context.exception)) - - @mock.Mock('os_client_config.make_shade') - def test_create_res_missing_flavor(self, *mock_args): - # pylint: disable=unused-argument - tempest_resources = tempest.TempestResourcesManager() - with self.assertRaises(Exception) as context: - tempest_resources.create() - msg = 'Failed to create flavor' - self.assertTrue(msg in context.exception, msg=str(context.exception)) - @mock.patch('subprocess.check_output') def test_create_rally_deployment(self, mock_exec): self.assertEqual(conf_utils.create_rally_deployment(), None) diff --git a/functest/tests/unit/openstack/tempest/test_tempest.py b/functest/tests/unit/openstack/tempest/test_tempest.py index 9116100cd..2a1378572 100644 --- a/functest/tests/unit/openstack/tempest/test_tempest.py +++ b/functest/tests/unit/openstack/tempest/test_tempest.py @@ -57,7 +57,8 @@ class OSTempestTesting(unittest.TestCase): self.assertTrue( (msg % conf_utils.TEMPEST_CUSTOM) in context.exception) - def test_gen_tl_cm_default(self): + @mock.patch('os.remove') + def test_gen_tl_cm_default(self, *args): self.tempestcommon.mode = 'custom' with mock.patch('functest.opnfv_tests.openstack.tempest.tempest.' 'shutil.copyfile') as mock_copyfile, \ @@ -65,9 +66,12 @@ class OSTempestTesting(unittest.TestCase): 'os.path.isfile', return_value=True): self.tempestcommon.generate_test_list() self.assertTrue(mock_copyfile.called) + args[0].assert_called_once_with('/etc/tempest.conf') + @mock.patch('os.remove') + @mock.patch('shutil.copyfile') @mock.patch('subprocess.check_output') - def _test_gen_tl_mode_default(self, mode, mock_exec=None): + def _test_gen_tl_mode_default(self, mode, *args): self.tempestcommon.mode = mode if self.tempestcommon.mode == 'smoke': testr_mode = r"'^tempest\.(api|scenario).*\[.*\bsmoke\b.*\]$'" @@ -79,7 +83,8 @@ class OSTempestTesting(unittest.TestCase): cmd = "(cd {0}; stestr list {1} >{2} 2>/dev/null)".format( verifier_repo_dir, testr_mode, self.tempestcommon.list) self.tempestcommon.generate_test_list() - mock_exec.assert_called_once_with(cmd, shell=True) + args[0].assert_called_once_with(cmd, shell=True) + args[2].assert_called_once_with('/etc/tempest.conf') def test_gen_tl_smoke_mode(self): self._test_gen_tl_mode_default('smoke') @@ -185,8 +190,6 @@ class OSTempestTesting(unittest.TestCase): 'os.path.exists', return_value=False) @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.os.makedirs', side_effect=Exception) - @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.' - 'TempestResourcesManager.cleanup') def test_run_makedirs_ko(self, *args): # pylint: disable=unused-argument self.assertEqual(self.tempestcommon.run(), @@ -195,10 +198,6 @@ class OSTempestTesting(unittest.TestCase): @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.' 'os.path.exists', return_value=False) @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.os.makedirs') - @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.' - 'TempestResourcesManager.create', side_effect=Exception) - @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.' - 'TempestResourcesManager.cleanup') def test_run_create_resources_ko(self, *args): # pylint: disable=unused-argument self.assertEqual(self.tempestcommon.run(), @@ -207,10 +206,6 @@ class OSTempestTesting(unittest.TestCase): @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.' 'os.path.exists', return_value=False) @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.os.makedirs') - @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.' - 'TempestResourcesManager.create', return_value={}) - @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.' - 'TempestResourcesManager.cleanup') @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.' 'TempestCommon.configure', side_effect=Exception) def test_run_configure_tempest_ko(self, *args): @@ -221,10 +216,6 @@ class OSTempestTesting(unittest.TestCase): @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.' 'os.path.exists', return_value=False) @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.os.makedirs') - @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.' - 'TempestResourcesManager.create', return_value={}) - @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.' - 'TempestResourcesManager.cleanup') @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.' 'TempestCommon.configure') def _test_run(self, status, *args): -- cgit 1.2.3-korg