'Specific test to check that the staff and instructor of the master
course are assigned to the CCX.'

@ddt.data(*AUTH_ATTRS)
def test_post_list_staff_master_course_in_ccx(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}
    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)
    self.assertEqual(len(outbox), 1)
    self.assertIn(self.coach.email, outbox[0].recipients())
    list_staff_master_course = list_with_level(self.course, 'staff')
    list_instructor_master_course = list_with_level(self.course, 'instructor')
    course_key = CourseKey.from_string(resp.data.get('ccx_course_id'))
    with ccx_course_cm(course_key) as course_ccx:
        list_staff_ccx_course = list_with_level(course_ccx, 'staff')
        list_instructor_ccx_course = list_with_level(course_ccx, 'instructor')
    self.assertEqual((len(list_staff_master_course) + 1), len(list_staff_ccx_course))
    for course_user in list_staff_master_course:
        self.assertIn(course_user, list_staff_ccx_course)
    self.assertIn(self.coach, list_staff_ccx_course)
    self.assertEqual(len(list_instructor_master_course), len(list_instructor_ccx_course))
    for (course_user, ccx_user) in izip(sorted(list_instructor_master_course), sorted(list_instructor_ccx_course)):
        self.assertEqual(course_user, ccx_user)
