diff options
Diffstat (limited to 'roles/lib_openshift/src/test')
-rwxr-xr-x | roles/lib_openshift/src/test/integration/oc_user.yml | 4 | ||||
-rwxr-xr-x | roles/lib_openshift/src/test/unit/test_oc_user.py (renamed from roles/lib_openshift/src/test/unit/oc_user.py) | 16 |
2 files changed, 15 insertions, 5 deletions
diff --git a/roles/lib_openshift/src/test/integration/oc_user.yml b/roles/lib_openshift/src/test/integration/oc_user.yml index 7d6221e64..ad1f9d188 100755 --- a/roles/lib_openshift/src/test/integration/oc_user.yml +++ b/roles/lib_openshift/src/test/integration/oc_user.yml @@ -142,8 +142,8 @@ register: user_out - name: assert test group created assert: - that: user_out['results'][0]['metadata']['name'] == "integration-test-group" and - user_out['results'][0]['users'] is not defined + that: user_out['results']['results'][0]['metadata']['name'] == "integration-test-group" + msg: "{{ user_out }}" - name: create user with group membership oc_user: diff --git a/roles/lib_openshift/src/test/unit/oc_user.py b/roles/lib_openshift/src/test/unit/test_oc_user.py index 920b06d0e..933e96ae2 100755 --- a/roles/lib_openshift/src/test/unit/oc_user.py +++ b/roles/lib_openshift/src/test/unit/test_oc_user.py @@ -24,7 +24,7 @@ import mock # place class in our python path module_path = os.path.join('/'.join(os.path.realpath(__file__).split('/')[:-4]), 'library') # noqa: E501 sys.path.insert(0, module_path) -from oc_user import OCUser # noqa: E402 +from oc_user import OCUser, locate_oc_binary # noqa: E402 class OCUserTest(unittest.TestCase): @@ -36,8 +36,9 @@ class OCUserTest(unittest.TestCase): ''' setup method will create a file and set to known configuration ''' pass + @mock.patch('oc_user.Utils.create_tmpfile_copy') @mock.patch('oc_user.OCUser._run') - def test_state_list(self, mock_cmd): + def test_state_list(self, mock_cmd, mock_tmpfile_copy): ''' Testing a user list ''' params = {'username': 'testuser@email.com', 'state': 'list', @@ -65,13 +66,18 @@ class OCUserTest(unittest.TestCase): (0, user, ''), ] + mock_tmpfile_copy.side_effect = [ + '/tmp/mocked_kubeconfig', + ] + results = OCUser.run_ansible(params, False) self.assertFalse(results['changed']) self.assertTrue(results['results'][0]['metadata']['name'] == "testuser@email.com") + @mock.patch('oc_user.Utils.create_tmpfile_copy') @mock.patch('oc_user.OCUser._run') - def test_state_present(self, mock_cmd): + def test_state_present(self, mock_cmd, mock_tmpfile_copy): ''' Testing a user list ''' params = {'username': 'testuser@email.com', 'state': 'present', @@ -102,6 +108,10 @@ class OCUserTest(unittest.TestCase): (0, created_user, ''), # get ] + mock_tmpfile_copy.side_effect = [ + '/tmp/mocked_kubeconfig', + ] + results = OCUser.run_ansible(params, False) self.assertTrue(results['changed']) |