def test_main_no_testcaselist(self, mock_create_logs, mock_run, mock_parse, mock_get_list, mock_copy_patch, mock_copy_userconf, mock_update, mock_clean, mock_get_result, mock_utils, mock_config, mock_logger, mock_uuid, mock_os, mock_json, mock_open): mock_config.dovetail_config = {} mock_os.environ = {'DOVETAIL_HOME': 'dovetail_home'} logger_obj = Mock() logger_temp_obj = Mock() file_obj = Mock() logger_temp_obj.getLogger.return_value = logger_obj mock_logger.Logger.return_value = logger_temp_obj mock_open.return_value.__enter__.return_value = file_obj mock_json.dumps.return_value = 'results text' mock_uuid.uuid1.return_value = 42 mock_get_result.return_value = True mock_get_list.return_value = None kwargs_dict = { 'debug': True, 'opnfv_ci': False, 'report': True, 'testsuite': 'testsuite', 'docker_tag': '2.0.0', 'no_api_validation': False } with self.assertRaises(SystemExit) as cm: dt_run.main( ['--testsuite=testsuite', '--debug', '--report', '2.0.0']) expected = cm.exception self.assertEqual(expected.code, 2) logger_temp_obj.getLogger.assert_called_once_with() mock_logger.Logger.assert_called_once_with('run') mock_uuid.uuid1.assert_called_once_with() self.assertEqual({'build_tag': 'daily-master-42'}, mock_config.dovetail_config) mock_get_result.assert_called_once_with() mock_clean.assert_called_once_with() self.assertEqual( { 'DOVETAIL_HOME': 'dovetail_home', 'DEBUG': 'true', 'OPNFV_CI': 'false', 'validation': 'enabled' }, mock_os.environ) mock_create_logs.assert_called_once_with() logger_obj.info.assert_has_calls([ call('================================================'), call('Dovetail compliance: testsuite!'), call('================================================'), call('Build tag: daily-master-42') ]) mock_parse.assert_called_once_with(logger_obj, **kwargs_dict) mock_update.assert_called_once_with(logger_obj, **kwargs_dict) mock_copy_userconf.assert_called_once_with(logger_obj) mock_copy_patch.assert_called_once_with(logger_obj) mock_utils.check_docker_version.assert_called_once_with(logger_obj) mock_get_list.assert_called_once_with(logger_obj, **kwargs_dict)
def test_main(self, mock_create_logs, mock_run, mock_get_list, mock_copy_patch, mock_copy_userconf, mock_update, mock_parse, mock_clean, mock_get_result, mock_utils, mock_config, mock_logger, mock_uuid, mock_os): mock_config.dovetail_config = {} mock_os.environ = {} logger_obj = Mock() logger_temp_obj = Mock() logger_temp_obj.getLogger.return_value = logger_obj mock_logger.Logger.return_value = logger_temp_obj mock_uuid.uuid1.return_value = 42 mock_get_result.return_value = True testcase_list = ['testcase'] mock_get_list.return_value = testcase_list kwargs_dict = { 'debug': True, 'opnfv_ci': True, 'report': True, 'testsuite': 'testsuite', 'docker_tag': '2.0.0' } with self.assertRaises(SystemExit) as cm: dt_run.main(['--testsuite=testsuite', '--debug', '--report', '2.0.0', '--opnfv-ci']) expected = cm.exception logger_temp_obj.getLogger.assert_called_once_with() mock_logger.Logger.assert_called_once_with('run') mock_uuid.uuid1.assert_called_once_with() self.assertEquals({'build_tag': 'daily-master-42'}, mock_config.dovetail_config) mock_get_result.assert_called_once_with() mock_clean.assert_called_once_with() self.assertEquals({'DEBUG': 'true', 'OPNFV_CI': 'true'}, mock_os.environ) mock_create_logs.assert_called_once_with() logger_obj.info.assert_has_calls([ call('================================================'), call('Dovetail compliance: testsuite!'), call('================================================'), call('Build tag: daily-master-42')]) mock_parse.assert_called_once_with(logger_obj, **kwargs_dict) mock_update.assert_called_once_with(logger_obj, **kwargs_dict) mock_copy_userconf.assert_called_once_with(logger_obj) mock_copy_patch.assert_called_once_with(logger_obj) mock_utils.check_docker_version.assert_called_once_with(logger_obj) mock_get_list.assert_called_once_with(logger_obj, **kwargs_dict) mock_run.assert_called_once_with( testcase_list, kwargs_dict['report'], logger_obj) self.assertEquals(expected.code, 0)
def test_main_no_results_path(self, mock_get_result, mock_config, mock_uuid): mock_config.dovetail_config = {} mock_uuid.uuid1.return_value = 42 mock_get_result.return_value = False with self.assertRaises(SystemExit) as cm: dt_run.main(['2.0.0']) expected = cm.exception mock_uuid.uuid1.assert_called_once_with() self.assertEquals({'build_tag': 'daily-master-42'}, mock_config.dovetail_config) mock_get_result.assert_called_once_with() self.assertEquals(expected.code, 0)