diff options
author | Linda Wang <wangwulin@huawei.com> | 2017-05-18 07:17:27 +0000 |
---|---|---|
committer | Linda Wang <wangwulin@huawei.com> | 2017-05-19 08:40:59 +0000 |
commit | d55207785fc615c5236bf204a583285882b0672f (patch) | |
tree | 967ac269e2703417fe99c53189f2ea0f5b999490 /functest/tests/unit/openstack/tempest/test_conf_utils.py | |
parent | 9b36089c6a5f01e0770351d0e93b5f34410248a3 (diff) |
Replace CONST.* by getattribute/setattr for rally and tempest
Directories affected:
- functest/opnfv_tests/openstack/rally
- functest/opnfv_tests/openstack/tempest
and respective unit test
JIRA: FUNCTEST-796
Change-Id: I963f5947663f0b660337f3304defb697f5d338f3
Signed-off-by: Linda Wang <wangwulin@huawei.com>
Diffstat (limited to 'functest/tests/unit/openstack/tempest/test_conf_utils.py')
-rw-r--r-- | functest/tests/unit/openstack/tempest/test_conf_utils.py | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/functest/tests/unit/openstack/tempest/test_conf_utils.py b/functest/tests/unit/openstack/tempest/test_conf_utils.py index 8ca5cc5b..e63f256d 100644 --- a/functest/tests/unit/openstack/tempest/test_conf_utils.py +++ b/functest/tests/unit/openstack/tempest/test_conf_utils.py @@ -54,12 +54,12 @@ class OSTempestConfUtilsTesting(unittest.TestCase): return_value=(mock.Mock(), None)), \ self.assertRaises(Exception) as context: - CONST.tempest_use_custom_images = True + CONST.__setattr__('tempest_use_custom_images', True) conf_utils.create_tempest_resources() msg = 'Failed to create image' self.assertTrue(msg in context) - CONST.tempest_use_custom_images = False + CONST.__setattr__('tempest_use_custom_images', False) conf_utils.create_tempest_resources(use_custom_images=True) msg = 'Failed to create image' self.assertTrue(msg in context) @@ -84,20 +84,20 @@ class OSTempestConfUtilsTesting(unittest.TestCase): 'os_utils.get_or_create_flavor', return_value=(mock.Mock(), None)), \ self.assertRaises(Exception) as context: - CONST.tempest_use_custom_images = True - CONST.tempest_use_custom_flavors = True + CONST.__setattr__('tempest_use_custom_images', True) + CONST.__setattr__('tempest_use_custom_flavors', True) conf_utils.create_tempest_resources() msg = 'Failed to create flavor' self.assertTrue(msg in context) - CONST.tempest_use_custom_images = True - CONST.tempest_use_custom_flavors = False + CONST.__setattr__('tempest_use_custom_images', True) + CONST.__setattr__('tempest_use_custom_flavors', False) conf_utils.create_tempest_resources(use_custom_flavors=False) msg = 'Failed to create flavor' self.assertTrue(msg in context) def test_get_verifier_id_missing_verifier(self): - CONST.tempest_deployment_name = 'test_deploy_name' + CONST.__setattr__('tempest_deployment_name', 'test_deploy_name') with mock.patch('functest.opnfv_tests.openstack.tempest.' 'conf_utils.subprocess.Popen') as mock_popen, \ self.assertRaises(Exception): @@ -108,7 +108,7 @@ class OSTempestConfUtilsTesting(unittest.TestCase): conf_utils.get_verifier_id(), def test_get_verifier_id_default(self): - CONST.tempest_deployment_name = 'test_deploy_name' + CONST.__setattr__('tempest_deployment_name', 'test_deploy_name') with mock.patch('functest.opnfv_tests.openstack.tempest.' 'conf_utils.subprocess.Popen') as mock_popen: mock_stdout = mock.Mock() @@ -120,7 +120,7 @@ class OSTempestConfUtilsTesting(unittest.TestCase): 'test_deploy_id') def test_get_verifier_deployment_id_missing_rally(self): - CONST.rally_deployment_name = 'test_rally_deploy_name' + CONST.__setattr__('tempest_deployment_name', 'test_deploy_name') with mock.patch('functest.opnfv_tests.openstack.tempest.' 'conf_utils.subprocess.Popen') as mock_popen, \ self.assertRaises(Exception): @@ -131,7 +131,7 @@ class OSTempestConfUtilsTesting(unittest.TestCase): conf_utils.get_verifier_deployment_id(), def test_get_verifier_deployment_id_default(self): - CONST.rally_deployment_name = 'test_rally_deploy_name' + CONST.__setattr__('tempest_deployment_name', 'test_deploy_name') with mock.patch('functest.opnfv_tests.openstack.tempest.' 'conf_utils.subprocess.Popen') as mock_popen: mock_stdout = mock.Mock() @@ -240,8 +240,8 @@ class OSTempestConfUtilsTesting(unittest.TestCase): mock.patch('__builtin__.open', mock.mock_open()), \ mock.patch('functest.opnfv_tests.openstack.tempest.' 'conf_utils.shutil.copyfile'): - CONST.dir_functest_test = 'test_dir' - CONST.refstack_tempest_conf_path = 'test_path' + CONST.__setattr__('dir_functest_test', 'test_dir') + CONST.__setattr__('refstack_tempest_conf_path', 'test_path') conf_utils.configure_tempest_defcore('test_dep_dir', img_flavor_dict) mset.assert_any_call('compute', 'image_ref', 'test_image_id') @@ -266,8 +266,8 @@ class OSTempestConfUtilsTesting(unittest.TestCase): mock.patch('__builtin__.open', mock.mock_open()), \ mock.patch('functest.opnfv_tests.openstack.tempest.' 'conf_utils.backup_tempest_config'): - CONST.dir_functest_test = 'test_dir' - CONST.OS_ENDPOINT_TYPE = None + CONST.__setattr__('dir_functest_test', 'test_dir') + CONST.__setattr__('OS_ENDPOINT_TYPE', None) conf_utils.\ configure_tempest_update_params('test_conf_file', IMAGE_ID=image_id, @@ -277,25 +277,25 @@ class OSTempestConfUtilsTesting(unittest.TestCase): self.assertTrue(mwrite.called) def test_configure_tempest_update_params_missing_image_id(self): - CONST.tempest_use_custom_images = True + CONST.__setattr__('tempest_use_custom_images', True) self._test_missing_param(('compute', 'image_ref', 'test_image_id'), 'test_image_id', None) def test_configure_tempest_update_params_missing_image_id_alt(self): - CONST.tempest_use_custom_images = True + CONST.__setattr__('tempest_use_custom_images', True) conf_utils.IMAGE_ID_ALT = 'test_image_id_alt' self._test_missing_param(('compute', 'image_ref_alt', 'test_image_id_alt'), None, None) def test_configure_tempest_update_params_missing_flavor_id(self): - CONST.tempest_use_custom_flavors = True + CONST.__setattr__('tempest_use_custom_flavors', True) self._test_missing_param(('compute', 'flavor_ref', 'test_flavor_id'), None, 'test_flavor_id') def test_configure_tempest_update_params_missing_flavor_id_alt(self): - CONST.tempest_use_custom_flavors = True + CONST.__setattr__('tempest_use_custom_flavors', True) conf_utils.FLAVOR_ID_ALT = 'test_flavor_id_alt' self._test_missing_param(('compute', 'flavor_ref_alt', 'test_flavor_id_alt'), None, |