'Simple test that the Library "User Access" view works.
Also tests that we can use the REST API to assign a user to a library.'

def test_manage_library_users(self):

    library = LibraryFactory.create()
    (extra_user, _) = self.create_non_staff_user()
    manage_users_url = reverse_library_url('manage_library_users', unicode(library.location.library_key))
    response = self.client.get(manage_users_url)
    self.assertEqual(response.status_code, 200)
    self.assertNotIn(extra_user.username, response.content)
    user_details_url = reverse_course_url('course_team_handler', library.location.library_key, kwargs={'email': extra_user.email})
    edit_response = self.client.ajax_post(user_details_url, {'role': LibraryUserRole.ROLE})
    self.assertIn(edit_response.status_code, (200, 204))
    response = self.client.get(manage_users_url)
    self.assertEqual(response.status_code, 200)
    self.assertIn(extra_user.username, response.content)
