'Testing a user list'

@mock.patch('oc_user.Utils.create_tmpfile_copy')
@mock.patch('oc_user.OCUser._run')
def test_state_present(self, mock_cmd, mock_tmpfile_copy):

    params = {'username': 'testuser@email.com', 'state': 'present', 'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'full_name': 'Test    User', 'groups': [], 'debug': False}
    created_user = '{\n                                                                                                        "kind":    "User",\n                                                                                                        "apiVersion":    "v1",\n                                                                                                        "metadata":    {\n                                                                                                                        "name":    "testuser@email.com",\n                                                                                                                        "selfLink":    "/oapi/v1/users/testuser@email.com",\n                                                                                                                        "uid":    "8d508039-f224-11e6-b83b-12e1a7285e80",\n                                                                                                                        "resourceVersion":    "38646241",\n                                                                                                                        "creationTimestamp":    "2017-02-13T19:42:28Z"\n                                                                                                        },\n                                                                                                        "fullName":    "Test    User",\n                                                                                                        "identities":    null,\n                                                                                                        "groups":    null\n                                                                                        }'
    mock_cmd.side_effect = [(1, '', 'Error    from    server:    users    "testuser@email.com"    not    found'), (1, '', 'Error    from    server:    users    "testuser@email.com"    not    found'), (0, 'user    "testuser@email.com"    created', ''), (0, created_user, '')]
    mock_tmpfile_copy.side_effect = ['/tmp/mocked_kubeconfig']
    results = OCUser.run_ansible(params, False)
    self.assertTrue(results['changed'])
    self.assertTrue((results['results']['results'][0]['metadata']['name'] == 'testuser@email.com'))
