'When exception raise from ``enroll_email`` assert that enrollment skipped for that staff or
instructor.'

def test_add_master_course_staff_to_ccx_with_exception(self):

    staff = self.make_staff()
    self.assertTrue(CourseStaffRole(self.course.id).has_user(staff))
    instructor = self.make_instructor()
    self.assertTrue(CourseInstructorRole(self.course.id).has_user(instructor))
    with mock.patch.object(CourseEnrollment, 'enroll_by_email', side_effect=CourseEnrollmentException()):
        add_master_course_staff_to_ccx(self.course, self.ccx_locator, self.ccx.display_name)
        self.assertFalse(CourseEnrollment.objects.filter(course_id=self.ccx_locator, user=staff).exists())
        self.assertFalse(CourseEnrollment.objects.filter(course_id=self.ccx_locator, user=instructor).exists())
    with mock.patch.object(CourseEnrollment, 'enroll_by_email', side_effect=SMTPException()):
        add_master_course_staff_to_ccx(self.course, self.ccx_locator, self.ccx.display_name)
        self.assertFalse(CourseEnrollment.objects.filter(course_id=self.ccx_locator, user=staff).exists())
        self.assertFalse(CourseEnrollment.objects.filter(course_id=self.ccx_locator, user=instructor).exists())
