本文整理汇总了Python中notifications.models.Notification.reads方法的典型用法代码示例。如果您正苦于以下问题:Python Notification.reads方法的具体用法?Python Notification.reads怎么用?Python Notification.reads使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类notifications.models.Notification
的用法示例。
在下文中一共展示了Notification.reads方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_achievement_notification_get_read
# 需要导入模块: from notifications.models import Notification [as 别名]
# 或者: from notifications.models.Notification import reads [as 别名]
def test_achievement_notification_get_read(self):
#with three we have enought to test
achieves = Achievement.objects.all()[:3]
user = User.objects.get(id=1)
r = get_redis_connection()
a_len = len(achieves)
for i in achieves:
notif = AchievementNotification(achievement=i, user=user)
time.sleep(1)
key = Notification.STORE_KEY_READ_FORMAT.format(user.id)
r.zadd(key, notif.date, notif.to_json())
# Get notifications
res = Notification.reads(user)[::-1]
self.assertEquals(a_len, len(res))
for i in range(len(res)):
before = achieves[i]
after = res[i]
self.assertEquals(before.id, after.achievement_id)