aboutsummaryrefslogtreecommitdiffstats
path: root/xtesting/tests/unit
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2018-08-10 13:04:11 +0200
committerCédric Ollivier <cedric.ollivier@orange.com>2018-08-12 12:26:23 +0200
commit2ad07442cebfaca7d5d70191f9ffca1cabdf4370 (patch)
treeb31f5dc76f026b3a567361b3c6cb5c392acf59fb /xtesting/tests/unit
parentf42e4276414e492afde19deb368c1e77d4dffbeb (diff)
Skip the selected testcase too0.35
It completes "Allow calling a skip test" [1] [1] https://gerrit.opnfv.org/gerrit/60655 Change-Id: I02499aed56e6b23563165ea1f17b476e12408823 Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com> (cherry picked from commit a9491ef0948f8fe3eb3772b6b6ae44d86bde7e9b)
Diffstat (limited to 'xtesting/tests/unit')
-rw-r--r--xtesting/tests/unit/ci/test_run_tests.py40
-rw-r--r--xtesting/tests/unit/ci/test_tier_handler.py2
2 files changed, 41 insertions, 1 deletions
diff --git a/xtesting/tests/unit/ci/test_run_tests.py b/xtesting/tests/unit/ci/test_run_tests.py
index de2af66d..3624d158 100644
--- a/xtesting/tests/unit/ci/test_run_tests.py
+++ b/xtesting/tests/unit/ci/test_run_tests.py
@@ -130,6 +130,8 @@ class RunTestsTesting(unittest.TestCase):
def test_run_tests_import_exception(self, *args):
mock_test = mock.Mock()
kwargs = {'get_name.return_value': 'test_name',
+ 'is_skipped.return_value': False,
+ 'is_enabled.return_value': True,
'needs_clean.return_value': False}
mock_test.configure_mock(**kwargs)
with self.assertRaises(Exception) as context:
@@ -145,6 +147,8 @@ class RunTestsTesting(unittest.TestCase):
def test_run_tests_default(self, *args):
mock_test = mock.Mock()
kwargs = {'get_name.return_value': 'test_name',
+ 'is_skipped.return_value': False,
+ 'is_enabled.return_value': True,
'needs_clean.return_value': True}
mock_test.configure_mock(**kwargs)
test_run_dict = {'module': 'test_module',
@@ -158,6 +162,42 @@ class RunTestsTesting(unittest.TestCase):
self.assertEqual(self.runner.overall_result,
run_tests.Result.EX_OK)
+ @mock.patch('xtesting.ci.run_tests.Runner.get_dict_by_test')
+ def test_run_tests_disabled(self, *args):
+ mock_test = mock.Mock()
+ kwargs = {'get_name.return_value': 'test_name',
+ 'is_skipped.return_value': False,
+ 'is_enabled.return_value': False,
+ 'needs_clean.return_value': True}
+ mock_test.configure_mock(**kwargs)
+ test_run_dict = {'module': 'test_module',
+ 'class': 'test_class'}
+ with mock.patch('xtesting.ci.run_tests.Runner.get_run_dict',
+ return_value=test_run_dict):
+ self.runner.clean_flag = True
+ self.runner.run_test(mock_test)
+ args[0].assert_not_called()
+ self.assertEqual(self.runner.overall_result,
+ run_tests.Result.EX_OK)
+
+ @mock.patch('xtesting.ci.run_tests.Runner.get_dict_by_test')
+ def test_run_tests_skipped(self, *args):
+ mock_test = mock.Mock()
+ kwargs = {'get_name.return_value': 'test_name',
+ 'is_skipped.return_value': True,
+ 'is_enabled.return_value': True,
+ 'needs_clean.return_value': True}
+ mock_test.configure_mock(**kwargs)
+ test_run_dict = {'module': 'test_module',
+ 'class': 'test_class'}
+ with mock.patch('xtesting.ci.run_tests.Runner.get_run_dict',
+ return_value=test_run_dict):
+ self.runner.clean_flag = True
+ self.runner.run_test(mock_test)
+ args[0].assert_not_called()
+ self.assertEqual(self.runner.overall_result,
+ run_tests.Result.EX_OK)
+
@mock.patch('xtesting.ci.run_tests.Runner.run_test',
return_value=TestCase.EX_OK)
def test_run_tier_default(self, *mock_methods):
diff --git a/xtesting/tests/unit/ci/test_tier_handler.py b/xtesting/tests/unit/ci/test_tier_handler.py
index 97ba5ab3..dd7e1b06 100644
--- a/xtesting/tests/unit/ci/test_tier_handler.py
+++ b/xtesting/tests/unit/ci/test_tier_handler.py
@@ -29,7 +29,7 @@ class TierHandlerTesting(unittest.TestCase):
self.tier = tier_handler.Tier(
'test_tier', 'test_order', 'test_ci_loop', description='test_desc')
self.testcase = tier_handler.TestCase(
- 'test_name', 'true', self.mock_depend, 'test_criteria',
+ 'test_name', 'true', False, self.mock_depend, 'test_criteria',
True, description='test_desc', project='project_name')
self.dependency = tier_handler.Dependency(
'test_installer', 'test_scenario')