From d22f950cae95350ae0b0518ceefb3bcfc4f17009 Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Thu, 27 Jun 2019 21:33:20 +0200 Subject: Rewrite kubernetes parsing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It now sets details and result thanks to 1 regex. It also prints the failure summary if needed. Change-Id: Ia89d6825134161cf6513924dac93281d677eada6 Signed-off-by: Cédric Ollivier --- functest_kubernetes/test_k8stest.py | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'functest_kubernetes/test_k8stest.py') diff --git a/functest_kubernetes/test_k8stest.py b/functest_kubernetes/test_k8stest.py index a94fdf88..81d92853 100644 --- a/functest_kubernetes/test_k8stest.py +++ b/functest_kubernetes/test_k8stest.py @@ -49,29 +49,15 @@ class K8sTests(unittest.TestCase): with self.assertRaises(TypeError): self.k8stesting.run_kubetest() - @mock.patch('functest_kubernetes.k8stest.os.path.isfile') - def test_error_logging(self, mock_isfile): - # pylint: disable=unused-argument - with mock.patch('functest_kubernetes.k8stest.' - 'subprocess.Popen') as mock_popen, \ - mock.patch.object(self.k8stesting, - '_K8sTesting__logger') as mock_logger: - mock_stdout = mock.Mock() - attrs = {'stdout.read.return_value': 'Error loading client'} - mock_stdout.configure_mock(**attrs) - mock_popen.return_value = mock_stdout - self.k8stesting.run() - mock_logger.exception.assert_called_with( - "Error with running kubetest:") - + @mock.patch('re.search') @mock.patch('six.moves.builtins.open', mock.mock_open()) @mock.patch('functest_kubernetes.k8stest.os.path.isfile') @mock.patch('functest_kubernetes.k8stest.subprocess.Popen') - def test_run(self, mock_open, mock_isfile): + def test_run(self, *args): self.assertEquals(self.k8stesting.run(), testcase.TestCase.EX_OK) - mock_isfile.assert_called() - mock_open.assert_called() + for loop in range(3): + args[loop].assert_called() if __name__ == "__main__": -- cgit 1.2.3-korg