summaryrefslogtreecommitdiffstats
path: root/dovetail/tests/unit
diff options
context:
space:
mode:
authorxudan <xudan16@huawei.com>2018-12-11 01:41:15 -0500
committerxudan <xudan16@huawei.com>2018-12-11 02:03:31 -0500
commit13e644d0ba893ddc5e2944c2e827fde7cd58ae72 (patch)
treecb4bc6a43179593a7ec7a1dfc3b3e5c7cfcc9ea6 /dovetail/tests/unit
parentbdbd7d405ac8603deed456e038cd13b0fde02b62 (diff)
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 <xudan16@huawei.com>
Diffstat (limited to 'dovetail/tests/unit')
-rw-r--r--dovetail/tests/unit/test_report.py60
-rw-r--r--dovetail/tests/unit/test_testcase.py8
2 files changed, 10 insertions, 58 deletions
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,11 +277,11 @@ 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)
@@ -294,47 +291,10 @@ class ReportTesting(unittest.TestCase):
@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')
def test_generate_no_cases(self, mock_save, mock_generate, mock_config):
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
@@ -411,20 +411,12 @@ class TestcaseTesting(unittest.TestCase):
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']))