Set default value for CONFIG_FUNCTEST_YAML
authorCédric Ollivier <cedric.ollivier@orange.com>
Fri, 19 May 2017 20:23:52 +0000 (22:23 +0200)
committerCédric Ollivier <cedric.ollivier@orange.com>
Fri, 19 May 2017 21:04:49 +0000 (23:04 +0200)
It calculates via the full path of env.py.

Change-Id: Ief958833f5116cdb116d0153d85a0ae03063ec5c
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
functest/tests/unit/utils/test_functest_utils.py
functest/utils/env.py
functest/utils/functest_utils.py
run_unit_tests.sh

index 0fe7e91..218f7f7 100644 (file)
@@ -55,7 +55,8 @@ class FunctestUtilsTesting(unittest.TestCase):
         self.testcase_dict = {'case_name': 'testname',
                               'criteria': self.criteria}
         self.parameter = 'general.openstack.image_name'
-        self.config_yaml = 'test_config_yaml-'
+        self.config_yaml = os.path.normpath(os.path.join(os.path.dirname(
+            os.path.abspath(__file__)), '../../../ci/config_functest.yaml'))
         self.db_url_env = 'http://foo/testdb'
         self.file_yaml = {'general': {'openstack': {'image_name':
                                                     'test_image_name'}}}
index c9629e1..3724ec9 100644 (file)
@@ -15,7 +15,9 @@ default_envs = {
     'INSTALLER_IP': None,
     'BUILD_TAG': None,
     'OS_ENDPOINT_TYPE': None,
-    'OS_AUTH_URL': None
+    'OS_AUTH_URL': None,
+    'CONFIG_FUNCTEST_YAML': os.path.normpath(os.path.join(os.path.dirname(
+        os.path.abspath(__file__)), '../ci/config_functest.yaml'))
 }
 
 
index bf30f56..284c797 100644 (file)
@@ -24,6 +24,7 @@ from six.moves import urllib
 import yaml
 from git import Repo
 
+from functest.utils import constants
 from functest.utils import decorators
 
 logger = logging.getLogger(__name__)
@@ -375,7 +376,7 @@ def get_parameter_from_yaml(parameter, file):
 
 
 def get_functest_config(parameter):
-    yaml_ = os.environ["CONFIG_FUNCTEST_YAML"]
+    yaml_ = constants.CONST.__getattribute__('CONFIG_FUNCTEST_YAML')
     return get_parameter_from_yaml(parameter, yaml_)
 
 
@@ -397,7 +398,7 @@ def get_testcases_file_dir():
 
 
 def get_functest_yaml():
-    with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:
+    with open(constants.CONST.__getattribute__('CONFIG_FUNCTEST_YAML')) as f:
         functest_yaml = yaml.safe_load(f)
     f.close()
     return functest_yaml
index 86096fa..c4973ab 100755 (executable)
@@ -33,7 +33,6 @@ git clone --depth 1 https://gerrit.opnfv.org/gerrit/releng releng-unittests
 pip install releng-unittests/modules/
 rm -fr releng-unittests
 
-export CONFIG_FUNCTEST_YAML=$(pwd)/functest/ci/config_functest.yaml
 nosetests --with-xunit \
          --with-coverage \
          --cover-tests \