def test_handle_not_passing_id_verified_cert(self): """ Test handling of a user who is not passing and is id verified and has a cert """ different_user = UserFactory() CourseEnrollmentFactory( user=different_user, course_id=self.course_run_key, is_active=True, mode=CourseMode.VERIFIED, ) GeneratedCertificateFactory( user=different_user, course_id=self.course_run_key, mode=GeneratedCertificate.MODES.verified, status=CertificateStatuses.generating, ) with mock.patch(PASSING_GRADE_METHOD, return_value=False): assert _set_regular_cert_status(different_user, self.course_run_key, self.enrollment_mode, self.grade) == \ CertificateStatuses.notpassing assert _generate_regular_certificate_task( different_user, self.course_run_key) is True assert not _can_generate_regular_certificate( different_user, self.course_run_key, self.enrollment_mode, self.grade)
def test_handle_valid_task(self): """ Test handling of a valid user/course run combo. We test generate_certificate_task() and _generate_regular_certificate_task() separately since they both generate a cert. """ assert _generate_regular_certificate_task(self.user, self.course_run_key) is True
def test_handle_invalid(self): """ Test handling of an invalid user/course run combo """ other_user = UserFactory() mode = None grade = None assert not _can_generate_regular_certificate(other_user, self.course_run_key, mode, grade) assert not generate_certificate_task(other_user, self.course_run_key) assert not _generate_regular_certificate_task(other_user, self.course_run_key)
def test_handle_audit_status(self): """ Test handling of a user who is not passing and is enrolled in audit mode """ different_user = UserFactory() mode = CourseMode.AUDIT CourseEnrollmentFactory( user=different_user, course_id=self.course_run_key, is_active=True, mode=mode, ) assert _set_regular_cert_status(different_user, self.course_run_key, mode, self.grade) is None assert not _generate_regular_certificate_task(different_user, self.course_run_key)