From 03610129690840704fdcdbf28188c695a263e46e Mon Sep 17 00:00:00 2001 From: Stamatis Katsaounis Date: Fri, 1 Feb 2019 16:43:28 +0200 Subject: Add Functest Rally test cases This patch adds all Rally testcases of Functest to Dovetail. Change-Id: I8b20bce9966e924fd5aac41bde5a30442394db05 Signed-off-by: Stamatis Katsaounis --- dovetail/tests/unit/test_report.py | 55 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'dovetail/tests') diff --git a/dovetail/tests/unit/test_report.py b/dovetail/tests/unit/test_report.py index 4e1214e2..be56e15c 100644 --- a/dovetail/tests/unit/test_report.py +++ b/dovetail/tests/unit/test_report.py @@ -557,6 +557,61 @@ class ReportTesting(unittest.TestCase): testcase_obj.name.assert_called_once_with() self.assertEquals(expected, result) + @patch('__builtin__.open') + @patch('dovetail.report.json') + @patch('dovetail.report.dt_cfg') + @patch('dovetail.report.dt_utils') + @patch('dovetail.report.os.path') + def test_functest_rally_crawler_crawl(self, mock_path, mock_utils, + mock_config, mock_json, mock_open): + logger_obj = Mock() + mock_config.dovetail_config = {'build_tag': 'tag'} + dt_report.FunctestCrawler.logger = logger_obj + mock_path.exists.return_value = True + file_path = 'file_path' + testcase_obj = Mock() + testcase_obj.validate_testcase.return_value = 'rally_full' + testcase_obj.name.return_value = 'name' + testcase_obj.sub_testcase.return_value = ['subt_a', 'subt_b', 'subt_c'] + file_obj = Mock() + mock_open.return_value.__enter__.side_effect = [[file_obj], file_obj] + data_dict = { + 'case_name': 'rally_full', + 'build_tag': 'tag-name', + 'criteria': 'criteria', + 'start_date': 'start_date', + 'stop_date': 'stop_date', + 'details': [{ + 'details': { + 'success': ['subt_a'], + 'failures': ['subt_b', 'subt_c'] + } + }] + } + + mock_json.loads.return_value = data_dict + mock_utils.get_duration.return_value = 'duration' + + crawler = dt_report.FunctestCrawler() + result = crawler.crawl(testcase_obj, [file_path, file_path]) + expected = {'criteria': 'criteria', 'timestart': 'start_date', + 'timestop': 'stop_date', 'duration': 'duration', + 'details': { + 'tests': 3, 'failures': 2, + 'success': ['subt_a'], 'errors': ['subt_b', 'subt_c'], + 'skipped': []}} + + mock_path.exists.assert_called_once_with(file_path) + mock_open.assert_called_with(file_path, 'r') + mock_json.loads.assert_called_with(file_obj) + mock_utils.get_duration.assert_called_once_with( + 'start_date', 'stop_date', logger_obj) + testcase_obj.set_results.assert_called_with(expected) + testcase_obj.validate_testcase.assert_called_once_with() + testcase_obj.sub_testcase.assert_called_once_with() + testcase_obj.name.assert_called_once_with() + self.assertEquals(expected, result) + @patch('__builtin__.open') @patch('dovetail.report.json.loads') @patch('dovetail.report.dt_cfg') -- cgit 1.2.3-korg