aboutsummaryrefslogtreecommitdiffstats
path: root/functest_kubernetes/test_k8stest.py
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2019-06-27 21:33:20 +0200
committerCédric Ollivier <cedric.ollivier@orange.com>2019-06-28 07:35:47 +0200
commitd22f950cae95350ae0b0518ceefb3bcfc4f17009 (patch)
treec704fa06c3f08347eabfd4da3ff865818361f377 /functest_kubernetes/test_k8stest.py
parentd1d3feacdbf061cf4115ceeadcb71d2142971757 (diff)
Rewrite kubernetes parsing
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 <cedric.ollivier@orange.com>
Diffstat (limited to 'functest_kubernetes/test_k8stest.py')
-rw-r--r--functest_kubernetes/test_k8stest.py22
1 files changed, 4 insertions, 18 deletions
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__":