diff options
author | Jose Lausuch <jose.lausuch@ericsson.com> | 2017-06-02 08:19:12 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-06-02 08:19:12 +0000 |
commit | 8fde61d643c17b012659d8343ab3c06526958a05 (patch) | |
tree | 58dd3f40df636e8726b07aa6598ff7c03544a54d /functest/tests/unit/ci/test_prepare_env.py | |
parent | cce3644b0b0186676de974d32e02219e2ae5dc50 (diff) | |
parent | 8e6b5934deef23386b8047b2f30a481ce42d32b8 (diff) |
Merge "Use CONST to retrieve db_url rather than getter function"
Diffstat (limited to 'functest/tests/unit/ci/test_prepare_env.py')
-rw-r--r-- | functest/tests/unit/ci/test_prepare_env.py | 23 |
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) |