'Verify that enterprise service errors are handled properly.'

@httpretty.activate
@override_settings(ENTERPRISE_SERVICE_WORKER_USERNAME='enterprise_worker')
def test_enterprise_course_enrollment_api_error(self):

    UserFactory.create(username='enterprise_worker', email=self.EMAIL, password=self.PASSWORD)
    CourseModeFactory.create(course_id=self.course.id, mode_slug=CourseMode.DEFAULT_MODE_SLUG, mode_display_name=CourseMode.DEFAULT_MODE_SLUG)
    self.mock_enterprise_course_enrollment_post_api_failure()
    self.assert_enrollment_status(expected_status=status.HTTP_400_BAD_REQUEST, enterprise_course_consent=True, as_server=True, username='enterprise_worker')
    self.assertEqual(httpretty.last_request().path, '/enterprise/api/v1/enterprise-course-enrollment/', 'No    request    was    made    to    the    mocked    enterprise-course-enrollment    API')
