diff options
author | Cédric Ollivier <cedric.ollivier@orange.com> | 2018-07-15 09:49:57 +0200 |
---|---|---|
committer | Cédric Ollivier <cedric.ollivier@orange.com> | 2018-07-15 10:27:49 +0200 |
commit | 3aee76caccf9701e2c90652a920c1bca66903bb8 (patch) | |
tree | 94347a35558f5d15030efc3e8e3d3f5d9ff98555 /xtesting/tests/unit/core | |
parent | 3030d25d2a25347b0b6c7fcdd14bfe31fc5a86b6 (diff) |
Allow dynamically skipping testcases0.52
Change-Id: I7cf47f0625bdb8345fef43b24c51bd84ef4486ea
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'xtesting/tests/unit/core')
-rw-r--r-- | xtesting/tests/unit/core/test_testcase.py | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/xtesting/tests/unit/core/test_testcase.py b/xtesting/tests/unit/core/test_testcase.py index e2f56f8f..6b83b97c 100644 --- a/xtesting/tests/unit/core/test_testcase.py +++ b/xtesting/tests/unit/core/test_testcase.py @@ -15,11 +15,10 @@ import logging import os import unittest -from xtesting.core import testcase - import mock import requests +from xtesting.core import testcase __author__ = "Cedric Ollivier <cedric.ollivier@orange.com>" @@ -108,6 +107,14 @@ class TestCaseTesting(unittest.TestCase): testcase.TestCase.EX_PUSH_TO_DB_ERROR) mock_function.assert_not_called() + @mock.patch('requests.post') + def test_pushdb_skipped_test(self, mock_function=None): + self.test.is_skipped = True + self.assertEqual( + self.test.push_to_db(), + testcase.TestCase.EX_PUSH_TO_DB_ERROR) + mock_function.assert_not_called() + def _get_data(self): return { "build_tag": os.environ['BUILD_TAG'], @@ -158,6 +165,10 @@ class TestCaseTesting(unittest.TestCase): data=json.dumps(self._get_data(), sort_keys=True), headers=self._headers) + def test_check_requirements(self): + self.test.check_requirements() + self.assertEqual(self.test.is_skipped, False) + def test_check_criteria_missing(self): self.test.criteria = None self.assertEqual(self.test.is_successful(), @@ -184,6 +195,11 @@ class TestCaseTesting(unittest.TestCase): self.assertEqual(self.test.is_successful(), testcase.TestCase.EX_OK) + def test_check_result_skip(self): + self.test.is_skipped = True + self.assertEqual(self.test.is_successful(), + testcase.TestCase.EX_TESTCASE_SKIPPED) + def test_check_result_lt(self): self.test.result = 50 self.assertEqual(self.test.is_successful(), @@ -233,6 +249,10 @@ class TestCaseTesting(unittest.TestCase): self.test.stop_time = 180 self.assertEqual(self.test.get_duration(), "02:59") + def test_get_duration_skipped_test(self): + self.test.is_skipped = True + self.assertEqual(self.test.get_duration(), "00:00") + def test_str_project_name_ko(self): self.test.project_name = None self.assertIn("<xtesting.core.testcase.TestCase object at", @@ -268,6 +288,14 @@ class TestCaseTesting(unittest.TestCase): self.assertIn(duration, message) self.assertIn('FAIL', message) + def test_str_skip(self): + self.test.is_skipped = True + message = str(self.test) + self.assertIn(self._project_name, message) + self.assertIn(self._case_name, message) + self.assertIn("00:00", message) + self.assertIn('SKIP', message) + def test_clean(self): self.assertEqual(self.test.clean(), None) |