aboutsummaryrefslogtreecommitdiffstats
path: root/functest
diff options
context:
space:
mode:
authorLinda Wang <wangwulin@huawei.com>2017-05-18 08:09:39 +0000
committerLinda Wang <wangwulin@huawei.com>2017-05-19 08:45:20 +0000
commita17b5fd4638c75c8e71ff42d8eb0d71e54177424 (patch)
tree24b0a734765d5a40c33811f471e893aa490d3ee1 /functest
parentf5c8f9dd175e462bf362b5c301205a3376a0d82b (diff)
Replace CONST.* by getattribute/setattr for refstack
Directories affected: - functest/opnfv_tests/openstack/refstack_client and respective unit test JIRA: FUNCTEST-796 Change-Id: I7f7047d44d71e82bcc1f66ec0b760ff30a13dbd5 Signed-off-by: Linda Wang <wangwulin@huawei.com>
Diffstat (limited to 'functest')
-rwxr-xr-xfunctest/opnfv_tests/openstack/refstack_client/refstack_client.py24
-rwxr-xr-xfunctest/opnfv_tests/openstack/refstack_client/tempest_conf.py8
-rw-r--r--functest/tests/unit/openstack/refstack_client/test_refstack_client.py24
3 files changed, 31 insertions, 25 deletions
diff --git a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
index 2a2718dd..5f1f3a1d 100755
--- a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
+++ b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
@@ -33,9 +33,9 @@ class RefstackClient(testcase.TestCase):
if "case_name" not in kwargs:
kwargs["case_name"] = "refstack_defcore"
super(RefstackClient, self).__init__(**kwargs)
- self.FUNCTEST_TEST = CONST.dir_functest_test
- self.CONF_PATH = CONST.refstack_tempest_conf_path
- self.DEFCORE_LIST = CONST.refstack_defcore_list
+ self.FUNCTEST_TEST = CONST.__getattribute__('dir_functest_test')
+ self.CONF_PATH = CONST.__getattribute__('refstack_tempest_conf_path')
+ self.DEFCORE_LIST = CONST.__getattribute__('refstack_defcore_list')
self.confpath = os.path.join(self.FUNCTEST_TEST,
self.CONF_PATH)
self.defcorelist = os.path.join(self.FUNCTEST_TEST,
@@ -45,7 +45,7 @@ class RefstackClient(testcase.TestCase):
cmd = ("cd {0};"
". .venv/bin/activate;"
- "cd -;".format(CONST.dir_refstack_client))
+ "cd -;".format(CONST.__getattribute__('dir_refstack_client')))
ft_utils.execute_command(cmd)
def run_defcore(self, conf, testlist):
@@ -53,7 +53,7 @@ class RefstackClient(testcase.TestCase):
cmd = ("cd {0};"
"./refstack-client test -c {1} -v --test-list {2};"
- "cd -;".format(CONST.dir_refstack_client,
+ "cd -;".format(CONST.__getattribute__('dir_refstack_client'),
conf,
testlist))
ft_utils.execute_command(cmd)
@@ -63,16 +63,16 @@ class RefstackClient(testcase.TestCase):
cmd = ("cd {0};"
"./refstack-client test -c {1} -v --test-list {2};"
- "cd -;".format(CONST.dir_refstack_client,
+ "cd -;".format(CONST.__getattribute__('dir_refstack_client'),
self.confpath,
self.defcorelist))
logger.info("Starting Refstack_defcore test case: '%s'." % cmd)
header = ("Refstack environment:\n"
" SUT: %s\n Scenario: %s\n Node: %s\n Date: %s\n" %
- (CONST.INSTALLER_TYPE,
- CONST.DEPLOY_SCENARIO,
- CONST.NODE_NAME,
+ (CONST.__getattribute__('INSTALLER_TYPE'),
+ CONST.__getattribute__('DEPLOY_SCENARIO'),
+ CONST.__getattribute__('NODE_NAME'),
time.strftime("%a %b %d %H:%M:%S %Z %Y")))
f_stdout = open(
@@ -202,9 +202,9 @@ class RefstackClient(testcase.TestCase):
class RefstackClientParser(object):
def __init__(self):
- self.FUNCTEST_TEST = CONST.dir_functest_test
- self.CONF_PATH = CONST.refstack_tempest_conf_path
- self.DEFCORE_LIST = CONST.refstack_defcore_list
+ self.FUNCTEST_TEST = CONST.__getattribute__('dir_functest_test')
+ self.CONF_PATH = CONST.__getattribute__('refstack_tempest_conf_path')
+ self.DEFCORE_LIST = CONST.__getattribute__('refstack_defcore_list')
self.confpath = os.path.join(self.FUNCTEST_TEST,
self.CONF_PATH)
self.defcorelist = os.path.join(self.FUNCTEST_TEST,
diff --git a/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py b/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
index 5c04253c..fbaad589 100755
--- a/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
+++ b/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
@@ -24,12 +24,14 @@ class TempestConf(object):
self.DEPLOYMENT_ID = conf_utils.get_verifier_deployment_id()
self.DEPLOYMENT_DIR = conf_utils.get_verifier_deployment_dir(
self.VERIFIER_ID, self.DEPLOYMENT_ID)
- self.confpath = os.path.join(CONST.dir_functest_test,
- CONST.refstack_tempest_conf_path)
+ self.confpath = os.path.join(
+ CONST.__getattribute__('dir_functest_test'),
+ CONST.__getattribute__('refstack_tempest_conf_path'))
def generate_tempestconf(self):
try:
- openstack_utils.source_credentials(CONST.openstack_creds)
+ openstack_utils.source_credentials(
+ CONST.__getattribute__('openstack_creds'))
img_flavor_dict = conf_utils.create_tempest_resources(
use_custom_images=True, use_custom_flavors=True)
conf_utils.configure_tempest_defcore(
diff --git a/functest/tests/unit/openstack/refstack_client/test_refstack_client.py b/functest/tests/unit/openstack/refstack_client/test_refstack_client.py
index 58ec5a07..8c149baa 100644
--- a/functest/tests/unit/openstack/refstack_client/test_refstack_client.py
+++ b/functest/tests/unit/openstack/refstack_client/test_refstack_client.py
@@ -17,10 +17,12 @@ from functest.utils.constants import CONST
class OSRefstackClientTesting(unittest.TestCase):
- _config = os.path.join(CONST.dir_functest_test,
- CONST.refstack_tempest_conf_path)
- _testlist = os.path.join(CONST.dir_functest_test,
- CONST.refstack_defcore_list)
+ _config = os.path.join(
+ CONST.__getattribute__('dir_functest_test'),
+ CONST.__getattribute__('refstack_tempest_conf_path'))
+ _testlist = os.path.join(
+ CONST.__getattribute__('dir_functest_test'),
+ CONST.__getattribute__('refstack_defcore_list'))
def setUp(self):
self.defaultargs = {'config': self._config,
@@ -28,12 +30,13 @@ class OSRefstackClientTesting(unittest.TestCase):
self.refstackclient = refstack_client.RefstackClient()
def test_source_venv(self):
- CONST.dir_refstack_client = 'test_repo_dir'
+ CONST.__setattr__('dir_refstack_client', 'test_repo_dir')
with mock.patch('functest.opnfv_tests.openstack.refstack_client.'
'refstack_client.ft_utils.execute_command') as m:
cmd = ("cd {0};"
". .venv/bin/activate;"
- "cd -;".format(CONST.dir_refstack_client))
+ "cd -;"
+ .format(CONST.__getattribute__('dir_refstack_client')))
self.refstackclient.source_venv()
m.assert_any_call(cmd)
@@ -44,9 +47,10 @@ class OSRefstackClientTesting(unittest.TestCase):
'refstack_client.ft_utils.execute_command') as m:
cmd = ("cd {0};"
"./refstack-client test -c {1} -v --test-list {2};"
- "cd -;".format(CONST.dir_refstack_client,
- config,
- testlist))
+ "cd -;"
+ .format(CONST.__getattribute__('dir_refstack_client'),
+ config,
+ testlist))
self.refstackclient.run_defcore(config, testlist)
m.assert_any_call(cmd)
@@ -62,7 +66,7 @@ class OSRefstackClientTesting(unittest.TestCase):
self.assertEqual(self.refstackclient.main(**kwargs), status)
if len(args) > 0:
args[0].assert_called_once_with(
- refstack_client.RefstackClient.result_dir)
+ refstack_client.RefstackClient.result_dir)
if len(args) > 1:
args