diff options
author | Morgan Richomme <morgan.richomme@orange.com> | 2017-05-10 07:53:46 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-05-10 07:53:46 +0000 |
commit | ce80dec85ee484d5c0cd6ed2a48c60529938a706 (patch) | |
tree | 0421a847abb8d90a6d9030c8d1c4a0a601c44cb0 /functest/tests/unit/core | |
parent | 1fc80d52c05b773bf9d1b1004d53c8e6ab36b655 (diff) | |
parent | a212763c3e9f4cf6d52200aa614e42a911c5dbf7 (diff) |
Merge changes from topic 'add_testcase_str'
* changes:
Remove the former results in DB url
Implement TestCase __str__()
Diffstat (limited to 'functest/tests/unit/core')
-rw-r--r-- | functest/tests/unit/core/test_testcase.py | 33 |
1 files changed, 33 insertions, 0 deletions
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) |