当前位置: 首页>>代码示例>>Python>>正文


Python GeneratedCertificate.course_ids_with_certs_for_user方法代码示例

本文整理汇总了Python中certificates.models.GeneratedCertificate.course_ids_with_certs_for_user方法的典型用法代码示例。如果您正苦于以下问题:Python GeneratedCertificate.course_ids_with_certs_for_user方法的具体用法?Python GeneratedCertificate.course_ids_with_certs_for_user怎么用?Python GeneratedCertificate.course_ids_with_certs_for_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在certificates.models.GeneratedCertificate的用法示例。


在下文中一共展示了GeneratedCertificate.course_ids_with_certs_for_user方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_refundable_when_certificate_exists

# 需要导入模块: from certificates.models import GeneratedCertificate [as 别名]
# 或者: from certificates.models.GeneratedCertificate import course_ids_with_certs_for_user [as 别名]
    def test_refundable_when_certificate_exists(self, cutoff_date):
        """ Assert that enrollment is not refundable once a certificat has been generated."""

        cutoff_date.return_value = datetime.now(pytz.UTC) + timedelta(days=1)

        self.assertTrue(self.enrollment.refundable())

        GeneratedCertificateFactory.create(
            user=self.user,
            course_id=self.course.id,
            status=CertificateStatuses.downloadable,
            mode='verified'
        )

        self.assertFalse(self.enrollment.refundable())
        self.assertFalse(
            self.enrollment.refundable(
                user_already_has_certs_for=GeneratedCertificate.course_ids_with_certs_for_user(self.user)
            )
        )

        # Assert that can_refund overrides this and allows refund
        self.enrollment.can_refund = True
        self.assertTrue(self.enrollment.refundable())
        self.assertTrue(
            self.enrollment.refundable(
                user_already_has_certs_for=GeneratedCertificate.course_ids_with_certs_for_user(self.user)
            )
        )
开发者ID:auvipy,项目名称:edx-platform,代码行数:31,代码来源:test_refunds.py

示例2: test_course_ids_with_certs_for_user

# 需要导入模块: from certificates.models import GeneratedCertificate [as 别名]
# 或者: from certificates.models.GeneratedCertificate import course_ids_with_certs_for_user [as 别名]
    def test_course_ids_with_certs_for_user(self):
        # Create one user with certs and one without
        student_no_certs = UserFactory()
        student_with_certs = UserFactory()
        student_with_certs.profile.allow_certificate = True
        student_with_certs.profile.save()

        # Set up a couple of courses
        course_1 = CourseFactory.create()
        course_2 = CourseFactory.create()

        # Generate certificates
        GeneratedCertificateFactory.create(
            user=student_with_certs,
            course_id=course_1.id,
            status=CertificateStatuses.downloadable,
            mode='honor'
        )
        GeneratedCertificateFactory.create(
            user=student_with_certs,
            course_id=course_2.id,
            status=CertificateStatuses.downloadable,
            mode='honor'
        )

        # User with no certs should return an empty set.
        self.assertSetEqual(
            GeneratedCertificate.course_ids_with_certs_for_user(student_no_certs),
            set()
        )
        # User with certs should return a set with the two course_ids
        self.assertSetEqual(
            GeneratedCertificate.course_ids_with_certs_for_user(student_with_certs),
            {course_1.id, course_2.id}
        )
开发者ID:shevious,项目名称:edx-platform,代码行数:37,代码来源:tests.py


注:本文中的certificates.models.GeneratedCertificate.course_ids_with_certs_for_user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。