From b7ee5abe9b73cbc0928bf9ac080a6aecf05bcb7e Mon Sep 17 00:00:00 2001 From: xudan Date: Sat, 24 Nov 2018 01:44:02 -0500 Subject: Add ONAP VNF SDK verification tests Please refer to env_config.sh.onap.sample when testing it. The guide of preparing local env for onap package validation can be found here https://gerrit.onap.org/r/#/c/75119 Change-Id: I39d6b11544847756126623a7eb3b953dc800c470 Signed-off-by: xudan --- dovetail/tests/unit/test_test_runner.py | 37 +++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'dovetail/tests/unit/test_test_runner.py') diff --git a/dovetail/tests/unit/test_test_runner.py b/dovetail/tests/unit/test_test_runner.py index 2570ec76..4b5c00bb 100644 --- a/dovetail/tests/unit/test_test_runner.py +++ b/dovetail/tests/unit/test_test_runner.py @@ -323,7 +323,7 @@ class TestRunnerTesting(unittest.TestCase): @patch('dovetail.test_runner.os') def test_add_testcase_info(self, mock_os, mock_config): mock_os.getenv.side_effect = ['os_insecure', 'dovetail_home', 'debug', - 'os_cacert'] + 'os_cacert', 'host_url', 'csar_file'] mock_os.environ = {'DEPLOY_SCENARIO': 'deploy_scenario'} mock_config.dovetail_config = {'build_tag': 'build_tag'} @@ -332,7 +332,8 @@ class TestRunnerTesting(unittest.TestCase): 'testcase': 'testcase_name', 'os_insecure': 'os_insecure', 'deploy_scenario': 'deploy_scenario', 'dovetail_home': 'dovetail_home', 'debug': 'debug', - 'build_tag': 'build_tag', 'cacert': 'os_cacert'} + 'build_tag': 'build_tag', 'cacert': 'os_cacert', + 'host_url': 'host_url', 'csar_file': 'csar_file'} result = t_runner.FunctestRunner._add_testcase_info(self.testcase) self.testcase.validate_testcase.assert_called_once_with() @@ -639,3 +640,35 @@ class TestRunnerTesting(unittest.TestCase): 'pod_file': 'two', 'full_task_yaml': 'full_value'}, result) + + @patch('dovetail.test_runner.dt_utils') + @patch('dovetail.test_runner.os.path') + @patch('dovetail.test_runner.dt_cfg') + def test_init_onapvtprunner_no_env_file(self, mock_config, mock_path, + mock_utils): + t_runner.OnapVtpRunner.create_log() + mock_path.join.side_effect = ['env_file'] + mock_config.dovetail_config = {'config_dir': 'one', 'env_file': 'two'} + mock_path.isfile.return_value = False + + docker_runner = t_runner.OnapVtpRunner(self.testcase) + + mock_path.join.assert_has_calls([call('one', 'two')]) + mock_path.isfile.assert_called_once() + docker_runner.logger.error.assert_called_once_with( + 'File env_file does not exist.') + + @patch('dovetail.test_runner.dt_utils') + @patch('dovetail.test_runner.os.path') + @patch('dovetail.test_runner.dt_cfg') + def test_init_onapvtprunner(self, mock_config, mock_path, mock_utils): + t_runner.OnapVtpRunner.create_log() + mock_path.join.side_effect = ['env_file'] + mock_config.dovetail_config = {'config_dir': 'one', 'env_file': 'two'} + mock_path.isfile.return_value = True + + t_runner.OnapVtpRunner(self.testcase) + + mock_path.join.assert_has_calls([call('one', 'two')]) + mock_path.isfile.assert_called_once() + mock_utils.source_env.assert_called_once_with('env_file') -- cgit 1.2.3-korg