def test_can_be_added_to_allowlist_not_enrolled(self): """ Test to verify that a learner will be rejected from the allowlist without an active enrollmeint in a course-run. """ new_course_run = CourseFactory() assert not can_be_added_to_allowlist(self.user, new_course_run.id) # pylint: disable=no-member
def test_can_be_added_to_allowlist_is_already_on_allowlist(self): """ Test to verify that a learner will be rejected from the allowlist if they currently already appear on the allowlist. """ CertificateAllowlistFactory.create(course_id=self.course_run_key, user=self.user) assert not can_be_added_to_allowlist(self.user, self.course_run_key)
def update_allowlist(user, course, enable): """ Update the status of a user on the allowlist. """ if enable and can_be_added_to_allowlist(user, course): create_or_update_certificate_allowlist_entry(user, course, "Updated by mngmt cmd", enable) elif not enable: remove_allowlist_entry(user, course) else: print( f"Failed to process allowlist request for student {user.id} in course {course} and enable={enable}." )
def test_can_be_added_to_allowlist_certificate_invalidated(self): """ Test to verify that a learner will be rejected from the allowlist if they currently appear on the certificate invalidation list. """ certificate = GeneratedCertificateFactory.create( user=self.user, course_id=self.course_run_key, status=CertificateStatuses.unavailable, mode='verified') CertificateInvalidationFactory.create( generated_certificate=certificate, invalidated_by=self.global_staff, active=True) assert not can_be_added_to_allowlist(self.user, self.course_run_key)
def test_can_be_added_to_allowlist(self): """ Test to verify that a learner can be added to the allowlist that fits all needed criteria. """ assert can_be_added_to_allowlist(self.user, self.course_run_key)