本文整理汇总了Python中student.models.CourseEnrollment.enrollment_status_hash_cache_key方法的典型用法代码示例。如果您正苦于以下问题:Python CourseEnrollment.enrollment_status_hash_cache_key方法的具体用法?Python CourseEnrollment.enrollment_status_hash_cache_key怎么用?Python CourseEnrollment.enrollment_status_hash_cache_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类student.models.CourseEnrollment
的用法示例。
在下文中一共展示了CourseEnrollment.enrollment_status_hash_cache_key方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_save_deletes_cached_enrollment_status_hash
# 需要导入模块: from student.models import CourseEnrollment [as 别名]
# 或者: from student.models.CourseEnrollment import enrollment_status_hash_cache_key [as 别名]
def test_save_deletes_cached_enrollment_status_hash(self):
""" Verify the method deletes the cached enrollment status hash for the user. """
# There should be no cached value for a new user with no enrollments.
self.assertIsNone(cache.get(CourseEnrollment.enrollment_status_hash_cache_key(self.user)))
# Generating a status hash should cache the generated value.
status_hash = CourseEnrollment.generate_enrollment_status_hash(self.user)
self.assert_enrollment_status_hash_cached(self.user, status_hash)
# Modifying enrollments should delete the cached value.
CourseEnrollmentFactory.create(user=self.user)
self.assertIsNone(cache.get(CourseEnrollment.enrollment_status_hash_cache_key(self.user)))
示例2: assert_enrollment_status_hash_cached
# 需要导入模块: from student.models import CourseEnrollment [as 别名]
# 或者: from student.models.CourseEnrollment import enrollment_status_hash_cache_key [as 别名]
def assert_enrollment_status_hash_cached(self, user, expected_value):
self.assertEqual(cache.get(CourseEnrollment.enrollment_status_hash_cache_key(user)), expected_value)
示例3: test_enrollment_status_hash_cache_key
# 需要导入模块: from student.models import CourseEnrollment [as 别名]
# 或者: from student.models.CourseEnrollment import enrollment_status_hash_cache_key [as 别名]
def test_enrollment_status_hash_cache_key(self):
username = 'test-user'
user = UserFactory(username=username)
expected = 'enrollment_status_hash_' + username
self.assertEqual(CourseEnrollment.enrollment_status_hash_cache_key(user), expected)