aboutsummaryrefslogtreecommitdiffstats
path: root/functest/tests/unit/ci
diff options
context:
space:
mode:
Diffstat (limited to 'functest/tests/unit/ci')
-rw-r--r--functest/tests/unit/ci/test_prepare_env.py23
-rw-r--r--functest/tests/unit/ci/test_run_tests.py27
-rw-r--r--functest/tests/unit/ci/test_tier_builder.py1
-rw-r--r--functest/tests/unit/ci/test_tier_handler.py1
4 files changed, 30 insertions, 22 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)
diff --git a/functest/tests/unit/ci/test_run_tests.py b/functest/tests/unit/ci/test_run_tests.py
index 88e5d2b8..fb8cb391 100644
--- a/functest/tests/unit/ci/test_run_tests.py
+++ b/functest/tests/unit/ci/test_run_tests.py
@@ -38,8 +38,12 @@ class RunTestsTesting(unittest.TestCase):
'OS_PASSWORD': 'test_password'}
self.test = {'test_name': 'test_name'}
self.tier = mock.Mock()
+ test1 = mock.Mock()
+ test1.get_name.return_value = 'test1'
+ test2 = mock.Mock()
+ test2.get_name.return_value = 'test2'
attrs = {'get_name.return_value': 'test_tier',
- 'get_tests.return_value': ['test1', 'test2'],
+ 'get_tests.return_value': [test1, test2],
'get_ci_loop.return_value': 'test_ci_loop',
'get_test_names.return_value': ['test1', 'test2']}
self.tier.configure_mock(**attrs)
@@ -70,16 +74,6 @@ class RunTestsTesting(unittest.TestCase):
return_value=self.creds):
self.runner.source_rc_file()
- @mock.patch('functest.ci.run_tests.os_snapshot.main')
- def test_generate_os_snapshot(self, mock_os_snap):
- self.runner.generate_os_snapshot()
- self.assertTrue(mock_os_snap.called)
-
- @mock.patch('functest.ci.run_tests.os_clean.main')
- def test_cleanup(self, mock_os_clean):
- self.runner.cleanup()
- self.assertTrue(mock_os_clean.called)
-
def test_get_run_dict_if_defined_default(self):
mock_obj = mock.Mock()
with mock.patch('functest.ci.run_tests.'
@@ -137,8 +131,6 @@ class RunTestsTesting(unittest.TestCase):
@mock.patch('functest.ci.run_tests.Runner.print_separator')
@mock.patch('functest.ci.run_tests.Runner.source_rc_file')
- @mock.patch('functest.ci.run_tests.Runner.generate_os_snapshot')
- @mock.patch('functest.ci.run_tests.Runner.cleanup')
@mock.patch('importlib.import_module', name="module",
return_value=mock.Mock(test_class=mock.Mock(
side_effect=FakeModule)))
@@ -161,10 +153,10 @@ class RunTestsTesting(unittest.TestCase):
def test_run_tier_default(self, mock_logger_info):
with mock.patch('functest.ci.run_tests.Runner.print_separator'), \
mock.patch(
- 'functest.ci.run_tests.Runner.run_test') as mock_method:
+ 'functest.ci.run_tests.Runner.run_test',
+ return_value=TestCase.EX_OK) as mock_method:
self.runner.run_tier(self.tier)
- mock_method.assert_any_call('test1', 'test_tier')
- mock_method.assert_any_call('test2', 'test_tier')
+ mock_method.assert_any_call(mock.ANY, 'test_tier')
self.assertTrue(mock_logger_info.called)
@mock.patch('functest.ci.run_tests.logger.info')
@@ -237,7 +229,8 @@ class RunTestsTesting(unittest.TestCase):
with mock.patch('functest.ci.run_tests.tb.TierBuilder',
return_value=mock_obj), \
mock.patch('functest.ci.run_tests.Runner.source_rc_file'), \
- mock.patch('functest.ci.run_tests.Runner.run_test') as m:
+ mock.patch('functest.ci.run_tests.Runner.run_test',
+ return_value=TestCase.EX_OK) as m:
self.assertEqual(self.runner.main(**kwargs),
run_tests.Result.EX_OK)
self.assertTrue(m.called)
diff --git a/functest/tests/unit/ci/test_tier_builder.py b/functest/tests/unit/ci/test_tier_builder.py
index 989c0870..ab75e15b 100644
--- a/functest/tests/unit/ci/test_tier_builder.py
+++ b/functest/tests/unit/ci/test_tier_builder.py
@@ -24,7 +24,6 @@ class TierBuilderTesting(unittest.TestCase):
'case_name': 'test_name',
'criteria': 'test_criteria',
'blocking': 'test_blocking',
- 'clean_flag': 'test_clean_flag',
'description': 'test_desc'}
self.dic_tier = {'name': 'test_tier',
diff --git a/functest/tests/unit/ci/test_tier_handler.py b/functest/tests/unit/ci/test_tier_handler.py
index c93fffd3..1909ac22 100644
--- a/functest/tests/unit/ci/test_tier_handler.py
+++ b/functest/tests/unit/ci/test_tier_handler.py
@@ -34,7 +34,6 @@ class TierHandlerTesting(unittest.TestCase):
self.mock_depend,
'test_criteria',
'test_blocking',
- 'test_clean_flag',
description='test_desc')
self.dependency = tier_handler.Dependency('test_installer',