Merge "Add unit tests for K8sTesting's run and run_kubetest methods"
authorCedric Ollivier <cedric.ollivier@orange.com>
Tue, 10 Apr 2018 06:22:30 +0000 (06:22 +0000)
committerGerrit Code Review <gerrit@opnfv.org>
Tue, 10 Apr 2018 06:22:30 +0000 (06:22 +0000)
functest_kubernetes/test_k8stest.py

index 230b6e0..05f40e1 100644 (file)
@@ -61,6 +61,19 @@ class K8sTests(unittest.TestCase):
                 "Cannot run k8s testcases. Config file not found")
         mock_func.assert_called_with('not_file')
 
+    def test_run_kubetest_cmd_none(self):
+        self.k8stesting.cmd = None
+        with self.assertRaises(TypeError):
+            self.k8stesting.run_kubetest()
+
+    @mock.patch('functest_kubernetes.k8stest.os.path.isfile')
+    @mock.patch('functest_kubernetes.k8stest.subprocess.Popen')
+    def test_run(self, mock_open, mock_isfile):
+        self.assertEquals(self.k8stesting.run(),
+                          testcase.TestCase.EX_OK)
+        mock_isfile.assert_called()
+        mock_open.assert_called()
+
 
 if __name__ == "__main__":
     logging.disable(logging.CRITICAL)