Esempio n. 1
0
    def test_remove_allowlist_entry(self):
        """
        Test for removing an allowlist entry for a user in a given course-run.
        """
        CertificateAllowlistFactory.create(course_id=self.course_run_key, user=self.user)
        assert is_on_allowlist(self.user, self.course_run_key)

        result = remove_allowlist_entry(self.user, self.course_run_key)
        assert result
        assert not is_on_allowlist(self.user, self.course_run_key)
    def test_allowlist_entry_created(self):
        """
        Verify an allowlist entry can be made using the management command.
        """
        call_command("cert_whitelist", "--add",
                     f"{self.user.username},{self.user2.username}", "-c",
                     f"{self.course_run_key}")

        assert is_on_allowlist(self.user, self.course_run_key)

        assert is_on_allowlist(self.user2, self.course_run_key)
    def test_allowlist_removal(self):
        """
        Verify an allowlist entry can be removed using the management command.
        """
        CertificateAllowlistFactory.create(course_id=self.course_run_key,
                                           user=self.user)
        assert is_on_allowlist(self.user, self.course_run_key)

        call_command("cert_whitelist", "--del", f"{self.user.username}", "-c",
                     f"{self.course_run_key}")

        assert not is_on_allowlist(self.user, self.course_run_key)
    def test_bad_user_account(self):
        """
        Verify that the management command will continue processing when running into a user account problem.
        """
        call_command("cert_whitelist", "--add", f"gumby,{self.user.username}",
                     "-c", f"{self.course_run_key}")

        assert is_on_allowlist(self.user, self.course_run_key)
Esempio n. 5
0
    def test_is_on_allowlist_entry_disabled(self):
        """
        Test to verify that we will return False when the allowlist entry if it is disabled.
        """
        CertificateAllowlistFactory.create(course_id=self.course_run_key, user=self.user, allowlist=False)

        result = is_on_allowlist(self.user, self.course_run_key)
        assert not result
Esempio n. 6
0
    def test_is_on_allowlist(self):
        """
        Test to verify that we return True when an allowlist entry exists.
        """
        CertificateAllowlistFactory.create(course_id=self.course_run_key, user=self.user)

        result = is_on_allowlist(self.user, self.course_run_key)
        assert result
Esempio n. 7
0
    def test_remove_allowlist_entry_with_certificate(self):
        """
        Test for removing an allowlist entry. Verify that we also invalidate the certificate for the student.
        """
        CertificateAllowlistFactory.create(course_id=self.course_run_key, user=self.user)
        GeneratedCertificateFactory.create(
            user=self.user,
            course_id=self.course_run_key,
            status=CertificateStatuses.downloadable,
            mode='verified'
        )
        assert is_on_allowlist(self.user, self.course_run_key)

        result = remove_allowlist_entry(self.user, self.course_run_key)
        assert result

        certificate = GeneratedCertificate.objects.get(user=self.user, course_id=self.course_run_key)
        assert certificate.status == CertificateStatuses.unavailable
        assert not is_on_allowlist(self.user, self.course_run_key)
Esempio n. 8
0
def can_show_certificate_message(course, student, course_grade,
                                 certificates_enabled_for_course):
    """
    Returns True if a course certificate message can be shown
    """
    is_allowlisted = certs_api.is_on_allowlist(student, course.id)
    auto_cert_gen_enabled = auto_certificate_generation_enabled()
    has_active_enrollment = CourseEnrollment.is_enrolled(student, course.id)
    certificates_are_viewable = certs_api.certificates_viewable_for_course(
        course)

    return ((auto_cert_gen_enabled or certificates_enabled_for_course)
            and has_active_enrollment and certificates_are_viewable
            and (course_grade.passed or is_allowlisted))
Esempio n. 9
0
 def test_is_on_allowlist_expect_false(self):
     """
     Test to verify that we will not return False when no allowlist entry exists.
     """
     result = is_on_allowlist(self.user, self.course_run_key)
     assert not result