aboutsummaryrefslogtreecommitdiffstats
path: root/functest/tests/unit/ci/test_prepare_env.py
diff options
context:
space:
mode:
authorLinda Wang <wangwulin@huawei.com>2017-03-31 02:46:48 +0000
committerLinda Wang <wangwulin@huawei.com>2017-06-01 10:55:45 +0000
commit8e6b5934deef23386b8047b2f30a481ce42d32b8 (patch)
tree73d8e69e49eba8efc7f7173c0b74f9c42bb79ae9 /functest/tests/unit/ci/test_prepare_env.py
parent86aee2dcf004361b1516f28b0137b7c3fedfe8a5 (diff)
Use CONST to retrieve db_url rather than getter function
1. Remove get_db_url() 2. If TEST_DB_URL declared in env, update test_db_url in config_functest.yaml file during env preparation 3. No matter TEST_DB_URL declared in env or not, Result_DB = CONST.__getattribute__("results_test_db_url") JIRA: FUNCTEST-763 Change-Id: I20da7ef98bbcc56731e0ff7061b05c1dde6cbfc3 Signed-off-by: Linda Wang <wangwulin@huawei.com>
Diffstat (limited to 'functest/tests/unit/ci/test_prepare_env.py')
-rw-r--r--functest/tests/unit/ci/test_prepare_env.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/functest/tests/unit/ci/test_prepare_env.py b/functest/tests/unit/ci/test_prepare_env.py
index 513e7230..85d1918d 100644
--- a/functest/tests/unit/ci/test_prepare_env.py
+++ b/functest/tests/unit/ci/test_prepare_env.py
@@ -20,6 +20,7 @@ class PrepareEnvTesting(unittest.TestCase):
def setUp(self):
self.prepare_envparser = prepare_env.PrepareEnvParser()
+ self.db_url_env = 'http://foo/testdb'
@mock.patch('functest.ci.prepare_env.logger.info')
def test_print_separator(self, mock_logger_info):
@@ -297,6 +298,22 @@ class PrepareEnvTesting(unittest.TestCase):
prepare_env.patch_file('test_file')
self.assertTrue(m.called)
+ @mock.patch('functest.ci.prepare_env.ft_utils.get_functest_yaml',
+ return_value={'tkey1': 'tvalue1'})
+ @mock.patch('functest.ci.prepare_env.yaml.safe_load',
+ return_value={'test_scenario': {'tkey': 'tvalue'}})
+ @mock.patch('functest.ci.prepare_env.update_db_url')
+ def test_update_db_url(self, mock_db_url, mock_safe_load,
+ mock_get_functest_yaml):
+ CONST.__setattr__('DEPLOY_SCENARIO', 'default_scenario')
+ with mock.patch("__builtin__.open", mock.mock_open()), \
+ mock.patch('functest.ci.prepare_env.yaml.dump'), \
+ mock.patch.dict('functest.ci.prepare_env.os.environ',
+ {'TEST_DB_URL': self.db_url_env},
+ clear=True):
+ prepare_env.update_config_file()
+ self.assertTrue(mock_db_url.called)
+
@mock.patch('functest.ci.prepare_env.logger.info')
def test_verify_deployment_error(self, mock_logger_error):
mock_popen = mock.Mock()
@@ -418,14 +435,14 @@ class PrepareEnvTesting(unittest.TestCase):
@mock.patch('functest.ci.prepare_env.install_tempest')
@mock.patch('functest.ci.prepare_env.install_rally')
@mock.patch('functest.ci.prepare_env.verify_deployment')
- @mock.patch('functest.ci.prepare_env.patch_config_file')
+ @mock.patch('functest.ci.prepare_env.update_config_file')
@mock.patch('functest.ci.prepare_env.source_rc_file')
@mock.patch('functest.ci.prepare_env.create_directories')
@mock.patch('functest.ci.prepare_env.get_deployment_handler')
@mock.patch('functest.ci.prepare_env.check_env_variables')
@mock.patch('functest.ci.prepare_env.logger.info')
def test_main_start(self, mock_logger_info, mock_env_var, mock_dep_handler,
- mock_create_dir, mock_source_rc, mock_patch_config,
+ mock_create_dir, mock_source_rc, mock_update_config,
mock_verify_depl, mock_install_rally,
mock_install_temp, mock_create_flavor,
mock_check_env, mock_print_info):
@@ -438,7 +455,7 @@ class PrepareEnvTesting(unittest.TestCase):
self.assertTrue(mock_dep_handler.called)
self.assertTrue(mock_create_dir.called)
self.assertTrue(mock_source_rc.called)
- self.assertTrue(mock_patch_config.called)
+ self.assertTrue(mock_update_config.called)
self.assertTrue(mock_verify_depl.called)
self.assertTrue(mock_install_rally.called)
self.assertTrue(mock_install_temp.called)