'Test for successful patch'

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

    outbox = self.get_outbox()
    new_coach = AdminFactory.create()
    data = {'max_students_allowed': 111, 'display_name': 'CCX    Title', 'coach_email': new_coach.email}
    resp = self.client.patch(self.detail_url, data, format='json', HTTP_AUTHORIZATION=getattr(self, auth_attr))
    self.assertEqual(resp.status_code, status.HTTP_204_NO_CONTENT)
    ccx_from_db = CustomCourseForEdX.objects.get(id=self.ccx.id)
    self.assertEqual(ccx_from_db.max_student_enrollments_allowed, data['max_students_allowed'])
    self.assertEqual(ccx_from_db.display_name, data['display_name'])
    self.assertEqual(ccx_from_db.coach.email, data['coach_email'])
    coach_role_on_master_course = CourseCcxCoachRole(self.master_course_key)
    self.assertTrue(coach_role_on_master_course.has_user(new_coach))
    ccx_course_object = courses.get_course_by_id(self.ccx_key)
    self.assertTrue(CourseEnrollment.objects.filter(course_id=ccx_course_object.id, user=new_coach).exists())
    self.assertEqual(len(outbox), 1)
    self.assertIn(new_coach.email, outbox[0].recipients())
