'Testing a user list'

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

    params = {'username': 'testuser@email.com', 'state': 'list', 'kubeconfig': '/etc/origin/master/admin.kubeconfig', 'full_name': None, 'groups': [], 'debug': False}
    user = '{\n                                                            "kind":    "User",\n                                                            "apiVersion":    "v1",\n                                                            "metadata":    {\n                                                                            "name":    "testuser@email.com",\n                                                                            "selfLink":    "/oapi/v1/users/testuser@email.com",\n                                                                            "uid":    "02fee6c9-f20d-11e6-b83b-12e1a7285e80",\n                                                                            "resourceVersion":    "38566887",\n                                                                            "creationTimestamp":    "2017-02-13T16:53:58Z"\n                                                            },\n                                                            "fullName":    "Test    User",\n                                                            "identities":    null,\n                                                            "groups":    null\n                                            }'
    mock_cmd.side_effect = [(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'))
