test_kubernetes: mock file operations in test_ssh_key 65/40965/1
authorRoss Brattain <ross.b.brattain@intel.com>
Mon, 4 Sep 2017 03:18:31 +0000 (20:18 -0700)
committerRoss Brattain <ross.b.brattain@intel.com>
Mon, 4 Sep 2017 03:33:42 +0000 (20:33 -0700)
tests take too long and we should not be createing/deleting
files during unittests, filesystems operations introduce
too many external issues

Change-Id: I989c9d0a84187becdf63497c0c1ac6e10c5eac70
Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
tests/unit/benchmark/contexts/test_kubernetes.py

index b0ee792..4976a9f 100644 (file)
@@ -81,9 +81,14 @@ class KubernetesTestCase(unittest.TestCase):
         self.assertTrue(mock_get_rc_pods.called)
         self.assertTrue(mock_wait_until_running.called)
 
+    @mock.patch('{}.paramiko'.format(prefix), **{"resource_filename.return_value": ""})
+    @mock.patch('{}.pkg_resources'.format(prefix), **{"resource_filename.return_value": ""})
+    @mock.patch('{}.utils'.format(prefix))
+    @mock.patch('{}.open'.format(prefix), create=True)
     @mock.patch('{}.k8s_utils.delete_config_map'.format(prefix))
     @mock.patch('{}.k8s_utils.create_config_map'.format(prefix))
-    def test_ssh_key(self, mock_create, mock_delete):
+    def test_ssh_key(self, mock_create, mock_delete, mock_open, mock_utils, mock_resources,
+                     mock_paramiko):
 
         k8s_context = KubernetesContext()
         k8s_context.init(context_cfg)