aboutsummaryrefslogtreecommitdiffstats
path: root/functest/tests/unit/utils/test_functest_utils.py
diff options
context:
space:
mode:
authorMorgan Richomme <morgan.richomme@orange.com>2017-03-14 16:57:05 +0100
committerMorgan Richomme <morgan.richomme@orange.com>2017-03-15 09:23:00 +0100
commit0c194ede4dd9eb46b61af49e85527fcc368a8fca (patch)
tree325c5d854b5ab1c6e269f43ab363fe5b78dd1dde /functest/tests/unit/utils/test_functest_utils.py
parent11d59071a11fcec1ef9fcd323070c6d4f151c7cd (diff)
env variable support for test DB url
So far DB url was retrieved from configuration file If you want to use the CI chain (jenkins, testapi, test DB, functest, ..) then you have a problem calling functest will systematically point to the configuration from the repo Supporting env variable allow to avoid post processing in the configuration file and as a consequence offer the possibility to create a local DB to host local results Change-Id: Ie64b8b265827d7f5724c7066a8c173de8cf012e2 Signed-off-by: Morgan Richomme <morgan.richomme@orange.com>
Diffstat (limited to 'functest/tests/unit/utils/test_functest_utils.py')
-rw-r--r--functest/tests/unit/utils/test_functest_utils.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/functest/tests/unit/utils/test_functest_utils.py b/functest/tests/unit/utils/test_functest_utils.py
index bb8360119..8bfdb5e49 100644
--- a/functest/tests/unit/utils/test_functest_utils.py
+++ b/functest/tests/unit/utils/test_functest_utils.py
@@ -56,6 +56,7 @@ class FunctestUtilsTesting(unittest.TestCase):
self.testcase_dict = {'name': 'testname', 'criteria': self.criteria}
self.parameter = 'general.openstack.image_name'
self.config_yaml = 'test_config_yaml-'
+ self.db_url_env = 'http://foo/testdb'
self.file_yaml = {'general': {'openstack': {'image_name':
'test_image_name'}}}
@@ -196,8 +197,17 @@ class FunctestUtilsTesting(unittest.TestCase):
self.assertEqual(functest_utils.get_build_tag(),
self.build_tag)
+ def test_get_db_url_env_var(self):
+ with mock.patch.dict(os.environ,
+ {'TEST_DB_URL': self.db_url_env,
+ 'CONFIG_FUNCTEST_YAML':
+ "./functest/ci/config_functest.yaml"},
+ clear=True):
+ self.assertEqual(functest_utils.get_db_url(),
+ self.db_url_env)
+
@mock.patch('functest.utils.functest_utils.get_functest_config')
- def test_get_db_url(self, mock_get_functest_config):
+ def test_get_db_url_default(self, mock_get_functest_config):
mock_get_functest_config.return_value = self.db_url
self.assertEqual(functest_utils.get_db_url(), self.db_url)
mock_get_functest_config.assert_called_once_with('results.test_db_url')