def test_achievement_notification_count_range(self): achieves = Achievement.objects.all()[:5] notifs = [] user = User.objects.get(id=1) r = get_redis_connection() for i in achieves: notif = AchievementNotification(achievement=i, user=user) time.sleep(1) if random.randrange(100) % 2: key = Notification.STORE_KEY_UNREAD_FORMAT.format(user.id) else: key = Notification.STORE_KEY_READ_FORMAT.format(user.id) r.zadd(key, notif.date, notif.to_json()) notifs.append(notif) achieves = achieves[2:5] # 2, 3 and 4 only a_len = len(achieves) lowerbound = notifs[2].date upperbound = notifs[4].date result = AchievementNotification.count(user, lowerbound, upperbound, mode=2) self.assertEquals(a_len, result)
def test_achievement_notification_count(self): achieves = Achievement.objects.all() user = User.objects.get(id=1) r = get_redis_connection() for i in achieves: notif = AchievementNotification(achievement=i, user=user) if random.randrange(100) % 2: key = Notification.STORE_KEY_UNREAD_FORMAT.format(user.id) else: key = Notification.STORE_KEY_READ_FORMAT.format(user.id) r.zadd(key, notif.date, notif.to_json()) a_len = len(achieves) self.assertEquals(a_len, AchievementNotification.count(user, mode=2))