'Creates four courses. Enroll test user in all courses
Sets two of them as pre-requisites of another course.
Checks course where pre-requisite course is set has appropriate info.'

@mock.patch.dict('django.conf.settings.FEATURES', {'ENABLE_PREREQUISITE_COURSES': True})
def test_course_listing_has_pre_requisite_courses(self):

    course_location2 = self.store.make_course_key('Org1', 'Course2', 'Run2')
    self._create_course_with_access_groups(course_location2)
    pre_requisite_course_location = self.store.make_course_key('Org1', 'Course3', 'Run3')
    self._create_course_with_access_groups(pre_requisite_course_location)
    pre_requisite_course_location2 = self.store.make_course_key('Org1', 'Course4', 'Run4')
    self._create_course_with_access_groups(pre_requisite_course_location2)
    pre_requisite_courses = [unicode(pre_requisite_course_location), unicode(pre_requisite_course_location2)]
    course_location = self.store.make_course_key('Org1', 'Course1', 'Run1')
    self._create_course_with_access_groups(course_location, {'pre_requisite_courses': pre_requisite_courses})
    set_prerequisite_courses(course_location, pre_requisite_courses)
    course_enrollments = list(get_course_enrollments(self.student, None, []))
    courses_having_prerequisites = frozenset((enrollment.course_id for enrollment in course_enrollments if enrollment.course_overview.pre_requisite_courses))
    courses_requirements_not_met = get_pre_requisite_courses_not_completed(self.student, courses_having_prerequisites)
    self.assertEqual(len(courses_requirements_not_met[course_location]['courses']), len(pre_requisite_courses))
