summaryrefslogtreecommitdiffstats
path: root/roles/lib_openshift/src/test/unit/oc_serviceaccount_secret.py
diff options
context:
space:
mode:
Diffstat (limited to 'roles/lib_openshift/src/test/unit/oc_serviceaccount_secret.py')
-rwxr-xr-xroles/lib_openshift/src/test/unit/oc_serviceaccount_secret.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/roles/lib_openshift/src/test/unit/oc_serviceaccount_secret.py b/roles/lib_openshift/src/test/unit/oc_serviceaccount_secret.py
index 342da961b..4d555d412 100755
--- a/roles/lib_openshift/src/test/unit/oc_serviceaccount_secret.py
+++ b/roles/lib_openshift/src/test/unit/oc_serviceaccount_secret.py
@@ -35,9 +35,10 @@ class OCServiceAccountSecretTest(unittest.TestCase):
''' setup method will create a file and set to known configuration '''
pass
+ @mock.patch('oc_serviceaccount_secret.Utils.create_tmpfile_copy')
@mock.patch('oc_serviceaccount_secret.Yedit._write')
@mock.patch('oc_serviceaccount_secret.OCServiceAccountSecret._run')
- def test_adding_a_secret_to_a_serviceaccount(self, mock_cmd, mock_write):
+ def test_adding_a_secret_to_a_serviceaccount(self, mock_cmd, mock_write, mock_tmpfile_copy):
''' Testing adding a secret to a service account '''
# Arrange
@@ -137,6 +138,10 @@ metadata:
(0, oc_get_sa_after, ''), # Fourth call to the mock
]
+ mock_tmpfile_copy.side_effect = [
+ '/tmp/mocked_kubeconfig',
+ ]
+
# Act
results = OCServiceAccountSecret.run_ansible(params, False)
@@ -149,18 +154,19 @@ metadata:
mock_cmd.assert_has_calls([
mock.call(['oc', '-n', 'default', 'get', 'sa', 'builder', '-o', 'json'], None),
mock.call(['oc', '-n', 'default', 'get', 'sa', 'builder', '-o', 'json'], None),
- mock.call(['oc', '-n', 'default', 'replace', '-f', '/tmp/builder'], None),
+ mock.call(['oc', '-n', 'default', 'replace', '-f', mock.ANY], None),
mock.call(['oc', '-n', 'default', 'get', 'sa', 'builder', '-o', 'json'], None)
])
mock_write.assert_has_calls([
- mock.call('/tmp/builder', builder_yaml_file)
+ mock.call(mock.ANY, builder_yaml_file)
])
+ @mock.patch('oc_serviceaccount_secret.Utils.create_tmpfile_copy')
@mock.patch('oc_serviceaccount_secret.Yedit._write')
@mock.patch('oc_serviceaccount_secret.OCServiceAccountSecret._run')
- def test_removing_a_secret_to_a_serviceaccount(self, mock_cmd, mock_write):
- ''' Testing adding a secret to a service account '''
+ def test_removing_a_secret_to_a_serviceaccount(self, mock_cmd, mock_write, mock_tmpfile_copy):
+ ''' Testing removing a secret to a service account '''
# Arrange
@@ -229,6 +235,10 @@ metadata:
(0, 'serviceaccount "builder" replaced', ''), # Third call to the mock
]
+ mock_tmpfile_copy.side_effect = [
+ '/tmp/mocked_kubeconfig',
+ ]
+
# Act
results = OCServiceAccountSecret.run_ansible(params, False)
@@ -241,11 +251,11 @@ metadata:
mock_cmd.assert_has_calls([
mock.call(['oc', '-n', 'default', 'get', 'sa', 'builder', '-o', 'json'], None),
mock.call(['oc', '-n', 'default', 'get', 'sa', 'builder', '-o', 'json'], None),
- mock.call(['oc', '-n', 'default', 'replace', '-f', '/tmp/builder'], None),
+ mock.call(['oc', '-n', 'default', 'replace', '-f', mock.ANY], None),
])
mock_write.assert_has_calls([
- mock.call('/tmp/builder', builder_yaml_file)
+ mock.call(mock.ANY, builder_yaml_file)
])
def tearDown(self):