'Tests the unenrollment of a list of students who are members of the class.
It tests 2 different views that use slightly different parameters,
but that perform the same task.'

@ddt.data(('ccx_invite', True, 1, 'student-ids', ('enrollment-button', 'Unenroll')), ('ccx_invite', False, 0, 'student-ids', ('enrollment-button', 'Unenroll')), ('ccx_manage_student', True, 1, 'student-id', ('student-action', 'revoke')), ('ccx_manage_student', False, 0, 'student-id', ('student-action', 'revoke')))
@ddt.unpack
def test_unenroll_member_student(self, view_name, send_email, outbox_count, student_form_input_name, button_tuple):

    self.make_coach()
    ccx = self.make_ccx()
    course_key = CCXLocator.from_course_locator(self.course.id, ccx.id)
    enrollment = CourseEnrollmentFactory(course_id=course_key)
    student = enrollment.user
    outbox = self.get_outbox()
    self.assertEqual(outbox, [])
    url = reverse(view_name, kwargs={'course_id': course_key})
    data = {button_tuple[0]: button_tuple[1], student_form_input_name: u','.join([student.email])}
    if send_email:
        data['email-students'] = 'Notify-students-by-email'
    response = self.client.post(url, data=data, follow=True)
    self.assertEqual(response.status_code, 200)
    self.assertEqual(len(response.redirect_chain), 1)
    self.assertIn(302, response.redirect_chain[0])
    self.assertEqual(len(outbox), outbox_count)
    if send_email:
        self.assertIn(student.email, outbox[0].recipients())
    self.assertFalse(CourseEnrollment.objects.filter(course_id=self.course.id, user=student).exists())
