'Enroll in the course and verify the response\'s status code. If the expected status is 200, also validates
the response content.
Returns
Response'

def assert_enrollment_status(self, course_id=None, username=None, expected_status=status.HTTP_200_OK, email_opt_in=None, as_server=False, mode=CourseMode.DEFAULT_MODE_SLUG, is_active=None, enrollment_attributes=None, min_mongo_calls=0, max_mongo_calls=0, enterprise_course_consent=None):

    course_id = (course_id or unicode(self.course.id))
    username = (username or self.user.username)
    data = {'mode': mode, 'course_details': {'course_id': course_id}, 'user': username, 'enrollment_attributes': enrollment_attributes}
    if (is_active is not None):
        data['is_active'] = is_active
    if (email_opt_in is not None):
        data['email_opt_in'] = email_opt_in
    if (enterprise_course_consent is not None):
        data['enterprise_course_consent'] = enterprise_course_consent
    extra = {}
    if as_server:
        extra['HTTP_X_EDX_API_KEY'] = self.API_KEY
    with check_mongo_calls_range(min_finds=min_mongo_calls, max_finds=max_mongo_calls):
        with patch('enrollment.views.audit_log') as mock_audit_log:
            url = reverse('courseenrollments')
            response = self.client.post(url, json.dumps(data), content_type='application/json', **extra)
            self.assertEqual(response.status_code, expected_status)
            if (expected_status == status.HTTP_200_OK):
                data = json.loads(response.content)
                self.assertEqual(course_id, data['course_details']['course_id'])
                if (mode is not None):
                    self.assertEqual(mode, data['mode'])
                if (is_active is not None):
                    self.assertEqual(is_active, data['is_active'])
                else:
                    self.assertTrue(data['is_active'])
                if as_server:
                    self.assertTrue(mock_audit_log.called)
                    mock_audit_log.reset_mock()
    return response
