From 13e644d0ba893ddc5e2944c2e827fde7cd58ae72 Mon Sep 17 00:00:00 2001 From: xudan Date: Tue, 11 Dec 2018 01:41:15 -0500 Subject: Enable ShellRunner 1. fix the bug 'ShellRunner' object has no attribute 'archive_logs' 2. remove the testarea_supported because it's not very necessary for the test cases themselves and can make it a little more simple to add a test case with new test area JIRA: DOVETAIL-750 Change-Id: I71ee74615200376adca2a0db040753e5fce329bc Signed-off-by: xudan --- dovetail/tests/unit/test_report.py | 60 ++++++------------------------------ dovetail/tests/unit/test_testcase.py | 8 ----- 2 files changed, 10 insertions(+), 58 deletions(-) (limited to 'dovetail/tests/unit') diff --git a/dovetail/tests/unit/test_report.py b/dovetail/tests/unit/test_report.py index fa5a02e0..0f0d3eec 100644 --- a/dovetail/tests/unit/test_report.py +++ b/dovetail/tests/unit/test_report.py @@ -173,7 +173,7 @@ class ReportTesting(unittest.TestCase): logger_obj = Mock() report = dt_report.Report() report.logger = logger_obj - testcase_list = ['t_a', 't_b'] + testcase_list = ['ta.tb.tc', 'td.te.tf'] duration = 42 mock_config.dovetail_config = { 'build_tag': 'build_tag' @@ -197,7 +197,7 @@ class ReportTesting(unittest.TestCase): 'duration': duration, 'testcases_list': [ { - 'name': 't_a', + 'name': 'ta.tb.tc', 'result': 'PASS', 'objective': 'objective', 'mandatory': True, @@ -207,7 +207,7 @@ class ReportTesting(unittest.TestCase): }] }, { - 'name': 't_b', + 'name': 'td.te.tf', 'result': 'Undefined', 'objective': '', 'mandatory': False, @@ -250,10 +250,7 @@ class ReportTesting(unittest.TestCase): logger_obj = Mock() report = dt_report.Report() report.logger = logger_obj - testcase_list = ['t_a', 't_b'] - mock_config.dovetail_config = { - 'testarea_supported': testcase_list - } + testcase_list = ['ta.tb.tc', 'td.te.tf'] duration = 42 report_data = { 'version': 'v2', @@ -262,7 +259,7 @@ class ReportTesting(unittest.TestCase): 'duration': 42.42, 'testcases_list': [ { - 'name': 't_a', + 'name': 'ta.tb.tc', 'result': 'PASS', 'sub_testcase': [{ 'name': 'subt_a', @@ -270,7 +267,7 @@ class ReportTesting(unittest.TestCase): }] }, { - 'name': 't_b', + 'name': 'td.te.tf', 'result': 'SKIP' } ] @@ -280,51 +277,17 @@ class ReportTesting(unittest.TestCase): result = report.generate(testcase_list, duration) expected = self._produce_report_initial_text(report_data) expected += 'Pass Rate: 100.00% (1/1)\n' - expected += '%-25s pass rate %.2f%%\n' % ('t_a:', 100) - expected += '-%-25s %s\n' % ('t_a', 'PASS') + expected += '%-25s pass rate %.2f%%\n' % ('tb:', 100) + expected += '-%-25s %s\n' % ('ta.tb.tc', 'PASS') expected += '\t%-110s %s\n' % ('subt_a', 'PASS') - expected += '%-25s all skipped\n' % 't_b' - expected += '-%-25s %s\n' % ('t_b', 'SKIP') + expected += '%-25s all skipped\n' % 'te' + expected += '-%-25s %s\n' % ('td.te.tf', 'SKIP') mock_generate.assert_called_once_with(testcase_list, duration) mock_save.assert_called_once_with(report_data) report.logger.info.assert_called_once_with(expected) self.assertEquals(expected, result) - @patch('dovetail.report.dt_cfg') - @patch.object(dt_report.Report, 'generate_json') - @patch.object(dt_report.Report, 'save_json_results') - def test_generate_error(self, mock_save, mock_generate, mock_config): - logger_obj = Mock() - report = dt_report.Report() - report.logger = logger_obj - mock_config.dovetail_config = { - 'testarea_supported': [] - } - testcase_list = ['t_a'] - duration = 42 - report_data = { - 'version': 'v2', - 'build_tag': '2.0.0', - 'test_date': '2018-01-13 13:13:13 UTC', - 'duration': 42.42, - 'testcases_list': [{ - 'name': 't_a', - 'result': 'PASS' - }] - } - mock_generate.return_value = report_data - - result = report.generate(testcase_list, duration) - expected = None - - mock_generate.assert_called_once_with(testcase_list, duration) - mock_save.assert_called_once_with(report_data) - report.logger.error.assert_called_once_with( - 'Test case {} not in supported testarea.' - .format(report_data['testcases_list'][0]['name'])) - self.assertEquals(expected, result) - @patch('dovetail.report.dt_cfg') @patch.object(dt_report.Report, 'generate_json') @patch.object(dt_report.Report, 'save_json_results') @@ -332,9 +295,6 @@ class ReportTesting(unittest.TestCase): logger_obj = Mock() report = dt_report.Report() report.logger = logger_obj - mock_config.dovetail_config = { - 'testarea_supported': [] - } duration = 42 report_data = { 'version': 'v2', diff --git a/dovetail/tests/unit/test_testcase.py b/dovetail/tests/unit/test_testcase.py index 0d303206..e2b0b744 100644 --- a/dovetail/tests/unit/test_testcase.py +++ b/dovetail/tests/unit/test_testcase.py @@ -410,21 +410,13 @@ class TestcaseTesting(unittest.TestCase): self.assertEquals((True, ['full']), tcase.Testcase.check_testarea(None)) - @patch('dovetail.testcase.dt_cfg') - def test_check_testarea_not_in_config(self, mock_config): - mock_config.dovetail_config = {'testarea_supported': []} - self.assertEquals((False, None), - tcase.Testcase.check_testarea(['area'])) - @patch('dovetail.testcase.dt_cfg') def test_check_testarea_full(self, mock_config): - mock_config.dovetail_config = {'testarea_supported': ['full']} self.assertEquals((True, ['full']), tcase.Testcase.check_testarea(['full'])) @patch('dovetail.testcase.dt_cfg') def test_check_testarea(self, mock_config): - mock_config.dovetail_config = {'testarea_supported': ['area']} self.assertEquals((True, ['area']), tcase.Testcase.check_testarea(['area'])) -- cgit 1.2.3-korg