def test_certificate_info_for_user_when_grade_changes( self, allowlisted, grade, output): """ Verify that certificate_info_for_user works as expect in scenario when grading of problems changes after certificates already generated. In such scenario `Certificate delivered` should not depend on student's eligibility to get certificates since in above scenario eligibility can change over period of time. """ student = UserFactory() certificate1 = GeneratedCertificateFactory.create( user=student, course_id=self.instructor_paced_course.id, status=CertificateStatuses.downloadable, mode='honor') certificate2 = GeneratedCertificateFactory.create( user=student, course_id=self.self_paced_course.id, status=CertificateStatuses.downloadable, mode='honor') # for instructor paced course certificate_info = certificate_info_for_user( student, self.instructor_paced_course.id, grade, allowlisted, certificate1) assert certificate_info == output # for self paced course certificate_info = certificate_info_for_user(student, self.self_paced_course.id, grade, allowlisted, certificate2) assert certificate_info == output
def _user_certificate_info(self, user, context, course_grade, bulk_certs): """ Returns the course certification information for the given user. """ is_allowlisted = user.id in bulk_certs.allowlisted_user_ids certificate_info = certs_api.certificate_info_for_user( user, context.course_id, course_grade.letter_grade, is_allowlisted, bulk_certs.certificates_by_user.get(user.id), ) return certificate_info
def test_certificate_info_for_user(self, allowlisted, grade, output): """ Verify that certificate_info_for_user works. """ student = UserFactory() # for instructor paced course certificate_info = certificate_info_for_user( student, self.instructor_paced_course.id, grade, allowlisted, user_certificate=None) assert certificate_info == output # for self paced course certificate_info = certificate_info_for_user(student, self.self_paced_course.id, grade, allowlisted, user_certificate=None) assert certificate_info == output
def test_certificate_info_for_user_with_course_modes( self, allowlisted, grade, mode, output): """ Verify that certificate_info_for_user works with course modes. """ user = UserFactory.create() _ = CourseEnrollment.enroll(user, self.instructor_paced_course.id, mode) certificate_info = certificate_info_for_user( user, self.instructor_paced_course.id, grade, allowlisted, user_certificate=None) assert certificate_info == output