Пример #1
0
 def test_cert_generation_on_whitelist_append_instructor_paced(self):
     """
     Verify that signal is sent, received, and fires task
     based on 'INSTRUCTOR_PACED_ONLY' flag
     """
     with mock.patch(
             'lms.djangoapps.certificates.signals.generate_certificate.apply_async',
             return_value=None
     ) as mock_generate_certificate_apply_async:
         with waffle.waffle().override(waffle.INSTRUCTOR_PACED_ONLY, active=False):
             CertificateWhitelist.objects.create(
                 user=self.user,
                 course_id=self.ip_course.id
             )
             mock_generate_certificate_apply_async.assert_not_called(
                 student=self.user,
                 course_key=self.ip_course.id
             )
         with waffle.waffle().override(waffle.INSTRUCTOR_PACED_ONLY, active=True):
             CertificateWhitelist.objects.create(
                 user=self.user,
                 course_id=self.ip_course.id
             )
             mock_generate_certificate_apply_async.assert_called_with(
                 student=self.user,
                 course_key=self.ip_course.id
             )
Пример #2
0
 def test_cert_generation_on_passing_instructor_paced(self):
     with mock.patch(
         'lms.djangoapps.certificates.signals.generate_certificate.apply_async',
         return_value=None
     ) as mock_generate_certificate_apply_async:
         with waffle.waffle().override(waffle.INSTRUCTOR_PACED_ONLY, active=True):
             grade_factory = CourseGradeFactory()
             with mock_get_score(0, 2):
                 grade_factory.update(self.user, self.ip_course)
                 mock_generate_certificate_apply_async.assert_not_called(
                     student=self.user,
                     course_key=self.ip_course.id
                 )
             with mock_get_score(1, 2):
                 grade_factory.update(self.user, self.ip_course)
                 mock_generate_certificate_apply_async.assert_called(
                     student=self.user,
                     course_key=self.ip_course.id
                 )
             # Certs are not re-fired after passing
             with mock_get_score(2, 2):
                 grade_factory.update(self.user, self.ip_course)
                 mock_generate_certificate_apply_async.assert_not_called(
                     student=self.user,
                     course_key=self.ip_course.id
                 )
Пример #3
0
 def test_cert_generation_on_whitelist_append_instructor_paced(self):
     """
     Verify that signal is sent, received, and fires task
     based on 'INSTRUCTOR_PACED_ONLY' flag
     """
     with mock.patch(
             'lms.djangoapps.certificates.signals.generate_certificate.apply_async',
             return_value=None) as mock_generate_certificate_apply_async:
         with waffle.waffle().override(waffle.INSTRUCTOR_PACED_ONLY,
                                       active=False):
             CertificateWhitelist.objects.create(
                 user=self.user, course_id=self.ip_course.id)
             mock_generate_certificate_apply_async.assert_not_called()
         with waffle.waffle().override(waffle.INSTRUCTOR_PACED_ONLY,
                                       active=True):
             CertificateWhitelist.objects.create(
                 user=self.user, course_id=self.ip_course.id)
             mock_generate_certificate_apply_async.assert_called_with(
                 student=self.user, course_key=self.ip_course.id)
Пример #4
0
 def test_cert_generation_on_passing_self_paced(self):
     with mock.patch(
             'lms.djangoapps.certificates.signals.generate_certificate.apply_async',
             return_value=None) as mock_generate_certificate_apply_async:
         with waffle.waffle().override(waffle.SELF_PACED_ONLY, active=True):
             grade_factory = CourseGradeFactory()
             # Not passing
             grade_factory.update(self.user, self.course)
             mock_generate_certificate_apply_async.assert_not_called()
             # Certs fired after passing
             with mock_passing_grade():
                 grade_factory.update(self.user, self.course)
                 mock_generate_certificate_apply_async.assert_called_with(
                     student=self.user, course_key=self.course.id)
Пример #5
0
    def test_cert_generation_on_photo_verification_self_paced(self):
        with mock.patch(
                'lms.djangoapps.certificates.signals.generate_certificate.apply_async',
                return_value=None) as mock_generate_certificate_apply_async:
            with mock_passing_grade():
                grade_factory = CourseGradeFactory()
                grade_factory.update(self.user_one, self.course_one)

            with waffle.waffle().override(waffle.SELF_PACED_ONLY, active=True):
                mock_generate_certificate_apply_async.assert_not_called()
                attempt = SoftwareSecurePhotoVerification.objects.create(
                    user=self.user_one, status='submitted')
                attempt.approve()
                mock_generate_certificate_apply_async.assert_called_with(
                    student=self.user_one, course_key=self.course_one.id)
Пример #6
0
 def test_cert_generation_on_passing_instructor_paced(self):
     with mock.patch(
             'lms.djangoapps.certificates.signals.generate_certificate.apply_async',
             return_value=None) as mock_generate_certificate_apply_async:
         with waffle.waffle().override(waffle.INSTRUCTOR_PACED_ONLY,
                                       active=True):
             grade_factory = CourseGradeFactory()
             with mock_get_score(0, 2):
                 grade_factory.update(self.user, self.ip_course)
                 mock_generate_certificate_apply_async.assert_not_called(
                     student=self.user, course_key=self.ip_course.id)
             with mock_get_score(1, 2):
                 grade_factory.update(self.user, self.ip_course)
                 mock_generate_certificate_apply_async.assert_called(
                     student=self.user, course_key=self.ip_course.id)
             # Certs are not re-fired after passing
             with mock_get_score(2, 2):
                 grade_factory.update(self.user, self.ip_course)
                 mock_generate_certificate_apply_async.assert_not_called(
                     student=self.user, course_key=self.ip_course.id)