From d467ead2a0d8585cd7b702804029ed514f26b513 Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Thu, 13 Apr 2017 16:52:16 +0200 Subject: Remove deprecated feature modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All features running bash programs are now simply defined in testcases.yaml. All deprecated modules and unit tests are removed. Change-Id: I7047b6f7a1e43cb8ed5ba2d569d5dcecae68fb86 Signed-off-by: Cédric Ollivier --- functest/tests/unit/core/test_feature.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'functest/tests/unit/core') diff --git a/functest/tests/unit/core/test_feature.py b/functest/tests/unit/core/test_feature.py index ac4b04c4..bd7197f0 100644 --- a/functest/tests/unit/core/test_feature.py +++ b/functest/tests/unit/core/test_feature.py @@ -17,6 +17,8 @@ import mock from functest.core import feature from functest.core import testcase +# logging must be disabled else it calls time.time() +# what will break these unit tests. logging.disable(logging.CRITICAL) @@ -27,10 +29,11 @@ class FeatureTestingBase(unittest.TestCase): _repo = "dir_repo_copper" _cmd = "cd /home/opnfv/repos/foo/tests && bash run.sh && cd -" _output_file = '/home/opnfv/functest/results/bar.log' + feature = None @mock.patch('time.time', side_effect=[1, 2]) def _test_run(self, status, mock_method=None): - self.assertEqual(self.feature.run(), status) + self.assertEqual(self.feature.run(cmd=self._cmd), status) if status == testcase.TestCase.EX_OK: self.assertEqual(self.feature.criteria, 'PASS') else: @@ -44,8 +47,15 @@ class FeatureTesting(FeatureTestingBase): def setUp(self): self.feature = feature.Feature( - project_name=self._project_name, case_name=self._case_name, - cmd=self._cmd) + project_name=self._project_name, case_name=self._case_name) + + def test_run_exc(self): + # pylint: disable=bad-continuation + with mock.patch.object( + self.feature, 'execute', + side_effect=Exception) as mock_method: + self._test_run(testcase.TestCase.EX_RUN_ERROR) + mock_method.assert_called_once_with(cmd=self._cmd) def test_run(self): self._test_run(testcase.TestCase.EX_RUN_ERROR) @@ -55,8 +65,12 @@ class BashFeatureTesting(FeatureTestingBase): def setUp(self): self.feature = feature.BashFeature( - project_name=self._project_name, case_name=self._case_name, - cmd=self._cmd) + project_name=self._project_name, case_name=self._case_name) + + @mock.patch("functest.utils.functest_utils.execute_command") + def test_run_no_cmd(self, mock_method=None): + self.assertEqual(self.feature.run(), testcase.TestCase.EX_RUN_ERROR) + mock_method.assert_not_called() @mock.patch("functest.utils.functest_utils.execute_command", return_value=1) -- cgit 1.2.3-korg