'Tests that CCX courses are filtered in course listing.'

def test_courses_list_with_ccx_courses(self):

    course_location = self.store.make_course_key('Org1', 'Course1', 'Run1')
    course = self._create_course_with_access_groups(course_location, self.user)
    ccx_course_key = CCXLocator.from_course_locator(course.id, '1')
    self._add_role_access_to_user(self.user, ccx_course_key)
    (courses_list, __) = _accessible_courses_list_from_groups(self.request)
    self.assertEqual(len(courses_list), 1)
    self.assertNotIn(ccx_course_key, [course.id for course in courses_list])
    instructor_courses = UserBasedRole(self.user, CourseInstructorRole.ROLE).courses_with_role()
    staff_courses = UserBasedRole(self.user, CourseStaffRole.ROLE).courses_with_role()
    all_courses = (instructor_courses | staff_courses)
    self.assertIn(ccx_course_key, [access.course_id for access in all_courses])
    mocked_ccx_course = Mock(id=ccx_course_key)
    with patch('xmodule.modulestore.mixed.MixedModuleStore.get_courses', return_value=[mocked_ccx_course]):
        (courses_iter, __) = _accessible_courses_iter(self.request)
        self.assertEqual(len(list(courses_iter)), 0)
