def test_follow_many_trim(self): follows = Follow.objects.filter(user=self.bogus_user)[:5] follow = follows[0] # reset the feed feed = DatabaseFallbackLoveFeed(follow.user_id) feed.delete() # do a follow feedly = LoveFeedly() max_loves = 3 feedly.follow_many(follows, async=False, max_loves=max_loves) # we should only have 3 items in the feed feed_count = feed.count() self.assertEqual(feed_count, max_loves) # but we should fallback to the database feed_results = feed[:20] self.assertEqual(len(feed_results), 20)
def test_follow_many(self): follows = Follow.objects.filter(user=self.bogus_user)[:5] follow = follows[0] # reset the feed feed = LoveFeed(follow.user_id) feed.delete() # do a follow feedly = LoveFeedly() feedly.follow_many(follows, async=False) # see if we got the new loves for follow in follows: target_loves = follow.target.get_profile().loves()[:10] for love in target_loves: activity = feedly.create_love_activity(love) assert feed.contains(activity) # check if we correctly broadcasted feedly.unfollow_many(follows) feed_count = feed.count() feed_results = feed[:20] self.assertEqual(feed_results, [])