def test_end_date_alert(self, current_time, expected_message_html): """ Verify that course end date alerts are registered. """ with freeze_time(current_time): block = CourseEndDate(self.course, self.request.user) block.register_alerts(self.request, self.course) messages = list(CourseHomeMessages.user_messages(self.request)) if expected_message_html: self.assertEqual(len(messages), 1) self.assertIn(expected_message_html, messages[0].message_html) else: self.assertEqual(len(messages), 0)
def test_course_end_date_for_non_certificate_eligible_mode(self): self.setup_course_and_user(days_till_start=-1, enrollment_mode=CourseMode.AUDIT) block = CourseEndDate(self.course, self.user) self.assertEqual(block.description, 'After this date, course content will be archived.') self.assertEqual(block.title, 'Course End')
def test_course_end_date_for_certificate_eligible_mode(self): self.setup_course_and_user(days_till_start=-1) block = CourseEndDate(self.course, self.user) self.assertEqual( block.description, 'To earn a certificate, you must complete all requirements before this date.' )
def test_course_end_date_after_course(self): self.setup_course_and_user(days_till_start=-2, days_till_end=-1) block = CourseEndDate(self.course, self.user) self.assertEqual( block.description, 'This course is archived, which means you can review course content but it is no longer active.' )
def test_course_end_date_for_certificate_eligible_mode(self): course = create_course_run(days_till_start=-1) user = create_user() CourseEnrollmentFactory(course_id=course.id, user=user, mode=CourseMode.VERIFIED) block = CourseEndDate(course, user) self.assertEqual( block.description, 'To earn a certificate, you must complete all requirements before this date.' )
def test_course_end_date_after_course(self): course = create_course_run(days_till_start=-2, days_till_end=-1) user = create_user() CourseEnrollmentFactory(course_id=course.id, user=user, mode=CourseMode.VERIFIED) block = CourseEndDate(course, user) self.assertEqual( block.description, 'This course is archived, which means you can review course content but it is no longer active.' ) self.assertEqual(block.title, 'Course End')
def test_course_end_date_for_non_certificate_eligible_mode(self): course = create_course_run(days_till_start=-1) user = create_user() CourseEnrollmentFactory(course_id=course.id, user=user, mode=CourseMode.AUDIT) block = CourseEndDate(course, user) self.assertEqual( block.description, 'After this date, course content will be archived.' ) self.assertEqual(block.title, 'Course End')