'Test that the correct list of enrollments is returned, depending on the permissions of the
requesting user.'

def test_enrollment_list_permissions(self):

    other_course = CourseFactory.create(emit_signals=True)
    for course in (self.course, other_course):
        CourseModeFactory.create(course_id=unicode(course.id), mode_slug=CourseMode.DEFAULT_MODE_SLUG, mode_display_name=CourseMode.DEFAULT_MODE_SLUG)
        self.assert_enrollment_status(course_id=unicode(course.id), max_mongo_calls=0)
    self._assert_enrollments_visible_in_list([self.course, other_course])
    self.client.login(username=self.OTHER_USERNAME, password=self.PASSWORD)
    self._assert_enrollments_visible_in_list([])
    staff_user = UserFactory.create(username='staff', email='staff@example.com', password=self.PASSWORD)
    CourseStaffRole(self.course.id).add_users(staff_user)
    self.client.login(username='staff', password=self.PASSWORD)
    self._assert_enrollments_visible_in_list([self.course])
    AdminFactory(username='global_staff', email='global_staff@example.com', password=self.PASSWORD)
    self.client.login(username='global_staff', password=self.PASSWORD)
    self._assert_enrollments_visible_in_list([self.course, other_course])
    self.client.logout()
    self._assert_enrollments_visible_in_list([self.course, other_course], use_server_key=True)
