diff options
author | Stamatis Katsaounis <mokats@intracom-telecom.com> | 2019-02-01 16:43:28 +0200 |
---|---|---|
committer | Dan Xu <xudan16@huawei.com> | 2019-03-08 09:21:49 +0000 |
commit | 03610129690840704fdcdbf28188c695a263e46e (patch) | |
tree | a683ff6363125915a9b3abddbaa6dbdd8b5fdf24 /dovetail/tests/unit/test_report.py | |
parent | ea480f97ea68b741a7b62ff07a38808871b568de (diff) |
Add Functest Rally test cases
This patch adds all Rally testcases of Functest to Dovetail.
Change-Id: I8b20bce9966e924fd5aac41bde5a30442394db05
Signed-off-by: Stamatis Katsaounis <mokats@intracom-telecom.com>
Diffstat (limited to 'dovetail/tests/unit/test_report.py')
-rw-r--r-- | dovetail/tests/unit/test_report.py | 55 |
1 files changed, 55 insertions, 0 deletions
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 @@ -558,6 +558,61 @@ class ReportTesting(unittest.TestCase): 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') @patch('dovetail.report.dt_utils') |