'With the right API key, deactivate (i.e., unenroll from) an existing enrollment.'

@ddt.data(((CourseMode.DEFAULT_MODE_SLUG,), CourseMode.DEFAULT_MODE_SLUG), ((CourseMode.DEFAULT_MODE_SLUG, CourseMode.VERIFIED), CourseMode.DEFAULT_MODE_SLUG), ((CourseMode.DEFAULT_MODE_SLUG, CourseMode.VERIFIED), CourseMode.VERIFIED), ((CourseMode.PROFESSIONAL,), CourseMode.PROFESSIONAL), ((CourseMode.NO_ID_PROFESSIONAL_MODE,), CourseMode.NO_ID_PROFESSIONAL_MODE), ((CourseMode.VERIFIED, CourseMode.CREDIT_MODE), CourseMode.VERIFIED), ((CourseMode.VERIFIED, CourseMode.CREDIT_MODE), CourseMode.CREDIT_MODE))
@ddt.unpack
def test_deactivate_enrollment(self, configured_modes, selected_mode):

    for mode in configured_modes:
        CourseModeFactory.create(course_id=self.course.id, mode_slug=mode, mode_display_name=mode)
    self.assert_enrollment_status(as_server=True, mode=selected_mode)
    self.assertTrue(CourseEnrollment.is_enrolled(self.user, self.course.id))
    (course_mode, is_active) = CourseEnrollment.enrollment_mode_for_user(self.user, self.course.id)
    self.assertTrue(is_active)
    self.assertEqual(course_mode, selected_mode)
    self.assert_enrollment_status(as_server=True, mode=None, is_active='foo', expected_status=status.HTTP_400_BAD_REQUEST)
    self.assert_enrollment_activation(False, selected_mode)
    self.assert_enrollment_activation(False, selected_mode)
    expected_status = (status.HTTP_200_OK if (CourseMode.DEFAULT_MODE_SLUG in configured_modes) else status.HTTP_400_BAD_REQUEST)
    self.assert_enrollment_status(as_server=True, is_active=False, expected_status=expected_status)
