diff options
Diffstat (limited to 'functest/tests/unit')
-rw-r--r-- | functest/tests/unit/ci/test_generate_report.py | 8 | ||||
-rw-r--r-- | functest/tests/unit/core/test_testcase.py | 33 |
2 files changed, 37 insertions, 4 deletions
diff --git a/functest/tests/unit/ci/test_generate_report.py b/functest/tests/unit/ci/test_generate_report.py index 13361c1d..2c5ce2ea 100644 --- a/functest/tests/unit/ci/test_generate_report.py +++ b/functest/tests/unit/ci/test_generate_report.py @@ -28,16 +28,16 @@ class GenerateReportTesting(unittest.TestCase): @mock.patch('functest.ci.generate_report.urllib2.urlopen', side_effect=urllib2.URLError('no host given')) def test_get_results_from_db_fail(self, mock_method): - url = "%s/results?build_tag=%s" % (ft_utils.get_db_url(), - CONST.__getattribute__('BUILD_TAG')) + url = "%s?build_tag=%s" % (ft_utils.get_db_url(), + CONST.__getattribute__('BUILD_TAG')) self.assertIsNone(gen_report.get_results_from_db()) mock_method.assert_called_once_with(url) @mock.patch('functest.ci.generate_report.urllib2.urlopen', return_value={'results': []}) def test_get_results_from_db_success(self, mock_method): - url = "%s/results?build_tag=%s" % (ft_utils.get_db_url(), - CONST.__getattribute__('BUILD_TAG')) + url = "%s?build_tag=%s" % (ft_utils.get_db_url(), + CONST.__getattribute__('BUILD_TAG')) self.assertEqual(gen_report.get_results_from_db(), None) mock_method.assert_called_once_with(url) diff --git a/functest/tests/unit/core/test_testcase.py b/functest/tests/unit/core/test_testcase.py index 17329ea3..b25ce226 100644 --- a/functest/tests/unit/core/test_testcase.py +++ b/functest/tests/unit/core/test_testcase.py @@ -189,6 +189,39 @@ class TestCaseTesting(unittest.TestCase): self.test.stop_time = 180 self.assertEqual(self.test.get_duration(), "02:59") + def test_str_project_name_ko(self): + self.test.project_name = None + self.assertIn("INVALID OBJECT", str(self.test)) + + def test_str_case_name_ko(self): + self.test.case_name = None + self.assertIn("INVALID OBJECT", str(self.test)) + + def test_str_pass(self): + duration = '01:01' + with mock.patch.object(self.test, 'get_duration', + return_value=duration), \ + mock.patch.object(self.test, 'is_successful', + return_value=testcase.TestCase.EX_OK): + message = str(self.test) + self.assertIn(self._project_name, message) + self.assertIn(self._case_name, message) + self.assertIn(duration, message) + self.assertIn('PASS', message) + + def test_str_fail(self): + duration = '00:59' + with mock.patch.object(self.test, 'get_duration', + return_value=duration), \ + mock.patch.object( + self.test, 'is_successful', + return_value=testcase.TestCase.EX_TESTCASE_FAILED): + message = str(self.test) + self.assertIn(self._project_name, message) + self.assertIn(self._case_name, message) + self.assertIn(duration, message) + self.assertIn('FAIL', message) + if __name__ == "__main__": unittest.main(verbosity=2) |