'Verify that if verified mode is expired than it\'s enrollment cannot be updated.'

@ddt.data((True, CourseMode.VERIFIED), (False, CourseMode.DEFAULT_MODE_SLUG))
@ddt.unpack
def test_update_enrollment_with_expired_mode(self, using_api_key, updated_mode):

    for mode in [CourseMode.DEFAULT_MODE_SLUG, CourseMode.VERIFIED]:
        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)
    mode = CourseMode.objects.get(course_id=self.course.id, mode_slug=CourseMode.VERIFIED)
    mode.expiration_datetime = datetime.datetime(year=1970, month=1, day=1, tzinfo=pytz.utc)
    mode.save()
    self.assert_enrollment_status(as_server=using_api_key, mode=CourseMode.VERIFIED, expected_status=(status.HTTP_200_OK if using_api_key else status.HTTP_403_FORBIDDEN))
    (course_mode, is_active) = CourseEnrollment.enrollment_mode_for_user(self.user, self.course.id)
    self.assertTrue(is_active)
    self.assertEqual(course_mode, updated_mode)
