'Change the student\'s enrollment status in a course.
Args:
action (str): The action to perform (either "enroll" or "unenroll")
Keyword Args:
course_id (unicode): If provided, use this course ID.  Otherwise, use the
course ID created in the setup for this test.
email_opt_in (unicode): If provided, pass this value along as
an additional GET parameter.
Returns:
Response'

def _change_enrollment(self, action, course_id=None, email_opt_in=None):

    if (course_id is None):
        course_id = unicode(self.course.id)
    params = {'enrollment_action': action, 'course_id': course_id}
    if email_opt_in:
        params['email_opt_in'] = email_opt_in
    return self.client.post(reverse('change_enrollment'), params)
