'Check response status is bad request when invalid enrollment
attributes are passed'

def test_enrollment_with_invalid_attr(self):

    for mode in [CourseMode.DEFAULT_MODE_SLUG, CourseMode.CREDIT_MODE]:
        CourseModeFactory.create(course_id=self.course.id, mode_slug=mode, mode_display_name=mode)
    self.assert_enrollment_status(as_server=True)
    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, CourseMode.DEFAULT_MODE_SLUG)
    enrollment_attributes = [{'namespace': 'credit', 'name': 'invalid', 'value': 'hogwarts'}]
    self.assert_enrollment_status(as_server=True, mode=CourseMode.CREDIT_MODE, expected_status=status.HTTP_400_BAD_REQUEST, enrollment_attributes=enrollment_attributes)
    (course_mode, is_active) = CourseEnrollment.enrollment_mode_for_user(self.user, self.course.id)
    self.assertTrue(is_active)
    self.assertEqual(course_mode, CourseMode.DEFAULT_MODE_SLUG)
