Ejemplo n.º 1
0
 def test_write_performance(self):
     return
     from entity.models import Love
     feedly = LoveFeedly()
     love = Love.objects.filter(user=self.bogus_user)[:10][0]
     activity = feedly.create_love_activity(love)
     feeds = feedly.add_love(love)
Ejemplo n.º 2
0
 def test_write_performance(self):
     return
     from entity.models import Love
     feedly = LoveFeedly()
     love = Love.objects.filter(user=self.bogus_user)[:10][0]
     activity = feedly.create_love_activity(love)
     feeds = feedly.add_love(love)
Ejemplo n.º 3
0
    def test_remove_love(self):
        love = Love.objects.filter(user=self.bogus_user)[:10][0]
        feedly = LoveFeedly()
        feedly.add_love(love)
        feeds = feedly.remove_love(love)

        activity = feedly.create_love_activity(love)
        for feed in feeds:
            love_added = feed.contains(activity)
            assert not love_added, 'the love should be added'
Ejemplo n.º 4
0
    def test_add_love(self):
        feedly = LoveFeedly()
        love = Love.objects.filter(user=self.bogus_user)[:10][0]
        activity = feedly.create_love_activity(love)
        feeds = feedly.add_love(love)

        # make the love was added to all feeds
        for feed in feeds:
            love_added = feed.contains(activity)
            assert love_added, 'the love should be added'
Ejemplo n.º 5
0
    def test_add_love(self):
        feedly = LoveFeedly()
        love = Love.objects.filter(user=self.bogus_user)[:10][0]
        activity = feedly.create_love_activity(love)
        feeds = feedly.add_love(love)

        # make the love was added to all feeds
        for feed in feeds:
            love_added = feed.contains(activity)
            assert love_added, 'the love should be added'
Ejemplo n.º 6
0
 def test_follower_groups(self):
     '''
     Make sure that users get the right feed.max_length
     '''
     feed = self.bogus_user.get_profile().get_feed()
     feedly = LoveFeedly()
     follower_groups = feedly.get_follower_groups(
         self.bogus_user, update_cache=True)
     for (user_group, max_length) in follower_groups:
         user_dict = User.objects.get_cached_users(
             user_group, update_cache=True)
         for user_id in user_group:
             user = user_dict[user_id]
             feed = user.get_profile().get_feed()
             self.assertEqual(feed.max_length, max_length)
Ejemplo n.º 7
0
 def test_follower_groups(self):
     '''
     Make sure that users get the right feed.max_length
     '''
     feed = self.bogus_user.get_profile().get_feed()
     feedly = LoveFeedly()
     follower_groups = feedly.get_follower_groups(self.bogus_user,
                                                  update_cache=True)
     for (user_group, max_length) in follower_groups:
         user_dict = User.objects.get_cached_users(user_group,
                                                   update_cache=True)
         for user_id in user_group:
             user = user_dict[user_id]
             feed = user.get_profile().get_feed()
             self.assertEqual(feed.max_length, max_length)
Ejemplo n.º 8
0
    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)
Ejemplo n.º 9
0
 def test_fanout_queries(self):
     '''
     Test to make sure the fanout task does no queries
     This makes it easier to setup a super efficient IO cluster for processing
     feedly tasks using celery
     '''
     from feedly.tasks import fanout_love
     from feedly.feed_managers.love_feedly import add_operation
     feedly = LoveFeedly()
     love = Love.objects.filter(user=self.bogus_user)[:10][0]
     activity = feedly.create_love_activity(love)
     fanout_partial = partial(fanout_love,
                              feedly,
                              love.user, [1, 2, 3],
                              add_operation,
                              max_length=2,
                              activity=activity)
     self.assertNumQueries(0, fanout_partial)
Ejemplo n.º 10
0
    def test_follow(self):
        follow = Follow.objects.filter(user=self.bogus_user)[:1][0]
        # reset the feed
        feed = LoveFeed(follow.user_id)
        feed.delete()
        # do a follow
        feedly = LoveFeedly()
        feed = feedly.follow(follow)
        # see if we got the new loves
        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(follow)
        feed_count = feed.count()
        feed_results = feed[:20]
        self.assertEqual(feed_results, [])
Ejemplo n.º 11
0
 def test_fanout_queries(self):
     '''
     Test to make sure the fanout task does no queries
     This makes it easier to setup a super efficient IO cluster for processing
     feedly tasks using celery
     '''
     from feedly.tasks import fanout_love
     from feedly.feed_managers.love_feedly import add_operation
     feedly = LoveFeedly()
     love = Love.objects.filter(user=self.bogus_user)[:10][0]
     activity = feedly.create_love_activity(love)
     fanout_partial = partial(
         fanout_love,
         feedly,
         love.user,
         [1, 2, 3],
         add_operation,
         max_length=2,
         activity=activity
     )
     self.assertNumQueries(0, fanout_partial)
Ejemplo n.º 12
0
    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, [])
Ejemplo n.º 13
0
    def test_remove_love(self):
        love = Love.objects.filter(user=self.bogus_user)[:10][0]
        feedly = LoveFeedly()
        feedly.add_love(love)
        feeds = feedly.remove_love(love)

        activity = feedly.create_love_activity(love)
        for feed in feeds:
            love_added = feed.contains(activity)
            assert not love_added, 'the love should be added'
Ejemplo n.º 14
0
    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)