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_label.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'roles/lib_openshift/src/test/unit/oc_label.py') diff --git a/roles/lib_openshift/src/test/unit/oc_label.py b/roles/lib_openshift/src/test/unit/oc_label.py index 3f7162070..3176987b0 100755 --- a/roles/lib_openshift/src/test/unit/oc_label.py +++ b/roles/lib_openshift/src/test/unit/oc_label.py @@ -35,8 +35,9 @@ class OCLabelTest(unittest.TestCase): ''' setup method will create a file and set to known configuration ''' pass + @mock.patch('oc_label.Utils.create_tmpfile_copy') @mock.patch('oc_label.OCLabel._run') - def test_state_list(self, mock_cmd): + def test_state_list(self, mock_cmd, mock_tmpfile_copy): ''' Testing a label list ''' params = {'name': 'default', 'namespace': 'default', @@ -82,13 +83,18 @@ class OCLabelTest(unittest.TestCase): (0, ns, ''), ] + mock_tmpfile_copy.side_effect = [ + '/tmp/mocked_kubeconfig', + ] + results = OCLabel.run_ansible(params, False) self.assertFalse(results['changed']) self.assertTrue(results['results']['labels'] == [{'storage_pv_quota': 'False'}]) + @mock.patch('oc_label.Utils.create_tmpfile_copy') @mock.patch('oc_label.OCLabel._run') - def test_state_present(self, mock_cmd): + def test_state_present(self, mock_cmd, mock_tmpfile_copy): ''' Testing a label list ''' params = {'name': 'default', 'namespace': 'default', @@ -171,6 +177,10 @@ class OCLabelTest(unittest.TestCase): (0, ns1, ''), ] + mock_tmpfile_copy.side_effect = [ + '/tmp/mocked_kubeconfig', + ] + results = OCLabel.run_ansible(params, False) self.assertTrue(results['changed']) -- cgit v1.2.3