Ejemplo n.º 1
0
    def test_get_allowlist_multiple_users(self):
        CertificateAllowlistFactory.create(course_id=self.course_run_key,
                                           user=self.user)
        CertificateAllowlistFactory.create(course_id=self.course_run_key,
                                           user=self.second_user)

        ret = CertificateAllowlist.get_certificate_allowlist(
            course_id=self.course_run_key)
        assert len(ret) == 2
Ejemplo n.º 2
0
    def test_get_allowlist_cert(self):
        allowlist_item = CertificateAllowlistFactory.create(
            course_id=self.course_run_key, user=self.user)
        cert = GeneratedCertificateFactory.create(
            status=CertificateStatuses.downloadable,
            user=self.user,
            course_id=self.course_run_key)

        ret = CertificateAllowlist.get_certificate_allowlist(
            course_id=self.course_run_key, student=self.user)
        assert len(ret) == 1

        item = ret[0]
        assert item['id'] == allowlist_item.id
        assert item['certificate_generated'] == cert.created_date.strftime(
            "%B %d, %Y")
Ejemplo n.º 3
0
    def test_get_allowlist_no_cert(self):
        allowlist_item = CertificateAllowlistFactory.create(
            course_id=self.course_run_key, user=self.user)
        CertificateAllowlistFactory.create(course_id=self.course_run_key,
                                           user=self.second_user)

        ret = CertificateAllowlist.get_certificate_allowlist(
            course_id=self.course_run_key, student=self.user)
        assert len(ret) == 1

        item = ret[0]
        assert item['id'] == allowlist_item.id
        assert item['user_id'] == self.user.id
        assert item['user_name'] == self.username
        assert item['user_email'] == self.user_email
        assert item['course_id'] == str(self.course_run_key)
        assert item['created'] == allowlist_item.created.strftime("%B %d, %Y")
        assert item['certificate_generated'] == ''
        assert item['notes'] == allowlist_item.notes
Ejemplo n.º 4
0
 def test_get_allowlist_empty(self):
     ret = CertificateAllowlist.get_certificate_allowlist(course_id=None,
                                                          student=None)
     assert len(ret) == 0
Ejemplo n.º 5
0
def get_allowlist(course_key):
    """
    Return the certificate allowlist for the given course run
    """
    return CertificateAllowlist.get_certificate_allowlist(course_key)