本文整理汇总了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)
)
)
示例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}
)