'Check that the list of enrollments of self.user returned for the currently logged in user
matches the list of courses passed in in \'courses\'.'

def _assert_enrollments_visible_in_list(self, courses, use_server_key=False):

    kwargs = {}
    if use_server_key:
        kwargs.update(HTTP_X_EDX_API_KEY=self.API_KEY)
    response = self.client.get(reverse('courseenrollments'), {'user': self.user.username}, **kwargs)
    self.assertEqual(response.status_code, status.HTTP_200_OK)
    data = json.loads(response.content)
    self.assertItemsEqual([(datum['course_details']['course_id'], datum['course_details']['course_name']) for datum in data], [(unicode(course.id), course.display_name_with_default) for course in courses])
