summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dovetail/report.py51
-rw-r--r--dovetail/tests/unit/test_report.py22
2 files changed, 51 insertions, 22 deletions
diff --git a/dovetail/report.py b/dovetail/report.py
index d40303e4..9523d388 100644
--- a/dovetail/report.py
+++ b/dovetail/report.py
@@ -319,29 +319,36 @@ class FunctestCrawler(Crawler):
testcase.set_results(json_results)
return json_results
- @staticmethod
- def get_details(data):
- t_details = data['details']
- details = {
- 'tests': t_details['tests_number'],
- 'failures': t_details['failures_number'],
- 'success': t_details['success'],
- 'errors': t_details['failures'],
- 'skipped': t_details['skipped']
- }
- return details
+ def get_details(self, data):
+ try:
+ t_details = data['details']
+ details = {
+ 'tests': t_details['tests_number'],
+ 'failures': t_details['failures_number'],
+ 'success': t_details['success'],
+ 'errors': t_details['failures'],
+ 'skipped': t_details['skipped']
+ }
+ return details
+ except Exception as e:
+ self.logger.exception("Failed to get details, {}.".format(e))
+ return None
- @staticmethod
- def get_rally_details(data):
- t_details = data['details'][0]['details']
- details = {
- 'tests': len(t_details['success']) + len(t_details['failures']),
- 'failures': len(t_details['failures']),
- 'success': t_details['success'],
- 'errors': t_details['failures'],
- 'skipped': []
- }
- return details
+ def get_rally_details(self, data):
+ try:
+ t_details = data['details'][0]['details']
+ tests = len(t_details['success']) + len(t_details['failures'])
+ details = {
+ 'tests': tests,
+ 'failures': len(t_details['failures']),
+ 'success': t_details['success'],
+ 'errors': t_details['failures'],
+ 'skipped': []
+ }
+ return details
+ except Exception as e:
+ self.logger.exception("Failed to get details, {}.".format(e))
+ return None
class FunctestK8sCrawler(FunctestCrawler):
diff --git a/dovetail/tests/unit/test_report.py b/dovetail/tests/unit/test_report.py
index fe6530c9..69cde0d5 100644
--- a/dovetail/tests/unit/test_report.py
+++ b/dovetail/tests/unit/test_report.py
@@ -640,6 +640,28 @@ class ReportTesting(unittest.TestCase):
'Result file not found: {}'.format(file_path))
self.assertEqual(None, result)
+ def test_functest_crawler_get_details_exception(self):
+ logger_obj = Mock()
+ dt_report.FunctestCrawler.logger = logger_obj
+ data = None
+ crawler = dt_report.FunctestCrawler()
+
+ excepted = None
+ result = crawler.get_details(data)
+ logger_obj.exception.assert_called_once()
+ self.assertEqual(excepted, result)
+
+ def test_functest_crawler_get_rally_details_exception(self):
+ logger_obj = Mock()
+ dt_report.FunctestCrawler.logger = logger_obj
+ data = None
+ crawler = dt_report.FunctestCrawler()
+
+ excepted = None
+ result = crawler.get_rally_details(data)
+ logger_obj.exception.assert_called_once()
+ self.assertEqual(excepted, result)
+
@patch('builtins.open')
@patch('dovetail.report.json')
@patch('dovetail.report.dt_cfg')