'Test the creation of a CCX'

@ddt.data(*AUTH_ATTRS)
def test_post_list(self, auth_attr):

    outbox = self.get_outbox()
    data = {'master_course_id': self.master_course_key_str, 'max_students_allowed': 111, 'display_name': 'CCX    Test    Title', 'coach_email': self.coach.email, 'course_modules': self.master_course_chapters[0:1]}
    resp = self.client.post(self.list_url, data, format='json', HTTP_AUTHORIZATION=getattr(self, auth_attr))
    self.assertEqual(resp.status_code, status.HTTP_201_CREATED)
    for (key, val) in data.iteritems():
        self.assertEqual(resp.data.get(key), val)
    self.assertIn('ccx_course_id', resp.data)
    course_key = CourseKey.from_string(resp.data.get('ccx_course_id'))
    ccx_course = CustomCourseForEdX.objects.get(pk=course_key.ccx)
    self.assertEqual(unicode(CCXLocator.from_course_locator(ccx_course.course.id, ccx_course.id)), resp.data.get('ccx_course_id'))
    coach_role_on_master_course = CourseCcxCoachRole(self.master_course_key)
    self.assertTrue(coach_role_on_master_course.has_user(self.coach))
    ccx_course_object = courses.get_course_by_id(course_key)
    self.assertTrue(CourseEnrollment.objects.filter(course_id=ccx_course_object.id, user=self.coach).exists())
    self.assertEqual(len(outbox), 1)
    self.assertIn(self.coach.email, outbox[0].recipients())
