コード例 #1
0
 def test_certificate_availability_alert(self, current_time, expected_message_html):
     """
     Verify the verified upgrade deadline alerts.
     """
     with freeze_time(current_time):
         block = CertificateAvailableDate(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)
コード例 #2
0
 def test_certificate_available_date_defined(self):
     course = create_course_run()
     audit_user = create_user()
     CourseEnrollmentFactory(course_id=course.id, user=audit_user, mode=CourseMode.AUDIT)
     verified_user = create_user()
     CourseEnrollmentFactory(course_id=course.id, user=verified_user, mode=CourseMode.VERIFIED)
     course.certificate_available_date = datetime.now(utc) + timedelta(days=7)
     enable_course_certificates(course)
     CertificateAvailableDate(course, audit_user)
     for block in (CertificateAvailableDate(course, audit_user), CertificateAvailableDate(course, verified_user)):
         self.assertIsNotNone(course.certificate_available_date)
         self.assertEqual(block.date, course.certificate_available_date)
         self.assertTrue(block.is_enabled)
コード例 #3
0
 def test_certificate_available_date_defined(self):
     course = create_course_run()
     audit_user = create_user()
     CourseEnrollmentFactory(course_id=course.id, user=audit_user, mode=CourseMode.AUDIT)
     verified_user = create_user()
     CourseEnrollmentFactory(course_id=course.id, user=verified_user, mode=CourseMode.VERIFIED)
     course.certificate_available_date = datetime.now(utc) + timedelta(days=7)
     enable_course_certificates(course)
     expected_blocks = [
         CourseEndDate, CourseStartDate, TodaysDate, VerificationDeadlineDate, CertificateAvailableDate
     ]
     self.assert_block_types(course, verified_user, expected_blocks)
     for block in (CertificateAvailableDate(course, audit_user), CertificateAvailableDate(course, verified_user)):
         assert course.certificate_available_date is not None
         assert block.date == course.certificate_available_date
         assert block.is_allowed
コード例 #4
0
 def test_no_certificate_available_date(self):
     course = create_course_run(days_till_start=-1)
     user = create_user()
     CourseEnrollmentFactory(course_id=course.id, user=user, mode=CourseMode.AUDIT)
     block = CertificateAvailableDate(course, user)
     assert block.date is None
     assert not block.is_allowed
コード例 #5
0
    def test_no_certificate_available_date_for_audit_course(self):
        """
        Tests that Certificate Available Date is not visible in the course "Important Course Dates" section
        if the course only has audit mode.
        """
        course = create_course_run()
        audit_user = create_user()

        # Enroll learner in the audit mode and verify the course only has 1 mode (audit)
        CourseEnrollmentFactory(course_id=course.id,
                                user=audit_user,
                                mode=CourseMode.AUDIT)
        CourseMode.objects.get(course_id=course.id,
                               mode_slug=CourseMode.VERIFIED).delete()
        all_course_modes = CourseMode.modes_for_course(course.id)
        self.assertEqual(len(all_course_modes), 1)
        self.assertEqual(all_course_modes[0].slug, CourseMode.AUDIT)

        course.certificate_available_date = datetime.now(utc) + timedelta(
            days=7)
        course.save()

        # Verify Certificate Available Date is not enabled for learner.
        block = CertificateAvailableDate(course, audit_user)
        self.assertFalse(block.is_enabled)
        self.assertNotEqual(block.date, None)
コード例 #6
0
 def test_no_certificate_available_date(self):
     course = create_course_run(days_till_start=-1)
     user = create_user()
     CourseEnrollmentFactory(course_id=course.id, user=user, mode=CourseMode.AUDIT)
     block = CertificateAvailableDate(course, user)
     self.assertEqual(block.date, None)
     self.assertFalse(block.is_enabled)
コード例 #7
0
 def test_no_certificate_available_date_for_self_paced(self):
     course = create_self_paced_course_run()
     verified_user = create_user()
     CourseEnrollmentFactory(course_id=course.id, user=verified_user, mode=CourseMode.VERIFIED)
     course.certificate_available_date = datetime.now(utc) + timedelta(days=7)
     course.save()
     block = CertificateAvailableDate(course, verified_user)
     assert block.date is not None
     assert not block.is_allowed