From 04ea66c4ab6cd1e5daa217526d7c9591aa164f10 Mon Sep 17 00:00:00 2001 From: Kenny Woodson Date: Wed, 8 Feb 2017 10:23:48 -0500 Subject: Added temporary kubeconfig file. Fixed tests to coincide with tmpfile. --- roles/lib_openshift/src/test/unit/oc_scale.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'roles/lib_openshift/src/test/unit/oc_scale.py') diff --git a/roles/lib_openshift/src/test/unit/oc_scale.py b/roles/lib_openshift/src/test/unit/oc_scale.py index d8d5a231f..f15eb164d 100755 --- a/roles/lib_openshift/src/test/unit/oc_scale.py +++ b/roles/lib_openshift/src/test/unit/oc_scale.py @@ -35,8 +35,9 @@ class OCScaleTest(unittest.TestCase): ''' setup method will create a file and set to known configuration ''' pass + @mock.patch('oc_scale.Utils.create_tmpfile_copy') @mock.patch('oc_scale.OCScale.openshift_cmd') - def test_state_list(self, mock_openshift_cmd): + def test_state_list(self, mock_openshift_cmd, mock_tmpfile_copy): ''' Testing a get ''' params = {'name': 'router', 'namespace': 'default', @@ -70,13 +71,18 @@ class OCScaleTest(unittest.TestCase): 'results': dc, 'returncode': 0}] + mock_tmpfile_copy.side_effect = [ + '/tmp/mocked_kubeconfig', + ] + results = OCScale.run_ansible(params, False) self.assertFalse(results['changed']) self.assertEqual(results['result'][0], 2) + @mock.patch('oc_scale.Utils.create_tmpfile_copy') @mock.patch('oc_scale.OCScale.openshift_cmd') - def test_scale(self, mock_openshift_cmd): + def test_scale(self, mock_openshift_cmd, mock_tmpfile_copy): ''' Testing a get ''' params = {'name': 'router', 'namespace': 'default', @@ -114,13 +120,18 @@ class OCScaleTest(unittest.TestCase): 'returncode': 0} ] + mock_tmpfile_copy.side_effect = [ + '/tmp/mocked_kubeconfig', + ] + results = OCScale.run_ansible(params, False) self.assertFalse(results['changed']) self.assertEqual(results['result'][0], 3) + @mock.patch('oc_scale.Utils.create_tmpfile_copy') @mock.patch('oc_scale.OCScale.openshift_cmd') - def test_no_dc_scale(self, mock_openshift_cmd): + def test_no_dc_scale(self, mock_openshift_cmd, mock_tmpfile_copy): ''' Testing a get ''' params = {'name': 'not_there', 'namespace': 'default', @@ -138,6 +149,10 @@ class OCScaleTest(unittest.TestCase): 'stdout': ""}, ] + mock_tmpfile_copy.side_effect = [ + '/tmp/mocked_kubeconfig', + ] + results = OCScale.run_ansible(params, False) self.assertTrue(results['failed']) -- cgit v1.2.3