aboutsummaryrefslogtreecommitdiffstats
path: root/xtesting/tests/unit/ci/test_run_tests.py
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2018-08-10 12:55:10 +0200
committerCédric Ollivier <cedric.ollivier@orange.com>2018-08-12 18:32:59 +0200
commit95092b511dbacac412dbe5b8ff3a28abb3d3f664 (patch)
tree24a547cf1a687af0d4db184375abcc03aef998ba /xtesting/tests/unit/ci/test_run_tests.py
parenta9491ef0948f8fe3eb3772b6b6ae44d86bde7e9b (diff)
Leverage on abc and stevedore
Change-Id: I7b3c4c0c5dd0c9e6fb3e52c3fff5221d4b831b02 Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'xtesting/tests/unit/ci/test_run_tests.py')
-rw-r--r--xtesting/tests/unit/ci/test_run_tests.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/xtesting/tests/unit/ci/test_run_tests.py b/xtesting/tests/unit/ci/test_run_tests.py
index 392612bd..423bf486 100644
--- a/xtesting/tests/unit/ci/test_run_tests.py
+++ b/xtesting/tests/unit/ci/test_run_tests.py
@@ -20,6 +20,10 @@ from xtesting.core.testcase import TestCase
class FakeModule(TestCase):
def run(self, **kwargs):
+ self.start_time = 0
+ self.stop_time = 1
+ self.criteria = 100
+ self.result = 100
return TestCase.EX_OK
@@ -140,9 +144,8 @@ class RunTestsTesting(unittest.TestCase):
msg = "Cannot import the class for the test case."
self.assertTrue(msg in str(context.exception))
- @mock.patch('importlib.import_module', name="module",
- return_value=mock.Mock(test_class=mock.Mock(
- side_effect=FakeModule)))
+ @mock.patch('stevedore.driver.DriverManager',
+ return_value=mock.Mock(driver=FakeModule()))
@mock.patch('xtesting.ci.run_tests.Runner.get_dict_by_test')
def test_run_tests_default(self, *args):
mock_test = mock.Mock()
@@ -151,14 +154,15 @@ class RunTestsTesting(unittest.TestCase):
'is_enabled.return_value': True,
'needs_clean.return_value': True}
mock_test.configure_mock(**kwargs)
- test_run_dict = {'module': 'test_module',
- 'class': 'test_class'}
+ test_run_dict = {'name': 'test_module'}
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)
+ self.assertEqual(self.runner.run_test(mock_test), TestCase.EX_OK)
args[0].assert_called_with('test_name')
- args[1].assert_called_with('test_module')
+ args[1].assert_called_with(
+ invoke_kwds=mock.ANY, invoke_on_load=True, name='test_module',
+ namespace='xtesting.testcase')
self.assertEqual(self.runner.overall_result,
run_tests.Result.EX_OK)
@@ -170,8 +174,7 @@ class RunTestsTesting(unittest.TestCase):
'is_enabled.return_value': False,
'needs_clean.return_value': True}
mock_test.configure_mock(**kwargs)
- test_run_dict = {'module': 'test_module',
- 'class': 'test_class'}
+ test_run_dict = {'name': 'test_name'}
with mock.patch('xtesting.ci.run_tests.Runner.get_run_dict',
return_value=test_run_dict):
self.runner.clean_flag = True