Esempio n. 1
0
    def test_add_love(self):
        # disable the follow notifications
        user_id = self.bogus_user.id
        self.set_setting(user_id, LoveVerb,
                         dict(notify_mobile=False, enabled=False))

        love = Love.objects.all()[:10][0]
        love.created_at = datetime.datetime.now()
        love.influencer_id = user_id
        influencer_feed = NotificationFeed(user_id)
        love.entity.created_by_id = self.bogus_user2.id
        creator_feed = NotificationFeed(self.bogus_user2.id)
        # we want to write two notifications
        # someone loved your find
        # someone loved your love
        notification_feedly = NotificationFeedly()
        # clean slate for testing
        influencer_feed.delete()
        creator_feed.delete()

        # comparison activity
        activity = love.create_activity()
        notification_feedly.add_love(love)

        # influencer is equal to user_id and shouldnt contain the activity
        assert not influencer_feed.contains(activity)

        # creator feed should contain since the settings hasn't been disabled
        creator_activity = copy.deepcopy(activity)
        creator_activity.extra_context['find'] = True
        assert creator_feed.contains(creator_activity)
Esempio n. 2
0
File: tests.py Progetto: etel/Feedly
    def test_follow_disabled(self):
        '''
        Verify that follows don't show up when you disable them in the settings
        '''
        from user.models import UserNotificationSetting
        # disable the follow notifications
        user_id = self.bogus_user.id
        self.set_setting(
            user_id, FollowVerb, dict(notify_mobile=False, enabled=False))

        # verify that we disabled
        enabled = UserNotificationSetting.objects.enabled_for(
            user_id, FollowVerb)
        self.assertFalse(enabled)

        notification_feedly = NotificationFeedly()
        follows = Follow.objects.all()[:10]

        # clear the feed
        notification_feed = NotificationFeed(user_id)
        notification_feed.delete()

        # make sure that notifications for follows don't show up
        for follow in follows:
            follow.user_id = self.bogus_user2.id
            follow.target_id = user_id
            follow.created_at = datetime.datetime.now()
            activity = follow.create_activity()
            feed = notification_feedly._follow(follow)
            if feed:
                assert not feed.contains(activity)

        # the count should be zero
        self.assertEqual(notification_feed.count_unseen(), 0)
Esempio n. 3
0
    def test_love(self):
        love = Love.objects.all()[:10][0]
        love.created_at = datetime.datetime.now()
        love.influencer_id = self.bogus_user.id
        influencer_feed = NotificationFeed(self.bogus_user.id)
        love.entity.created_by_id = self.bogus_user2.id
        creator_feed = NotificationFeed(self.bogus_user2.id)
        # we want to write two notifications
        # someone loved your find
        # someone loved your love
        notification_feedly = NotificationFeedly()
        # clean slate for testing
        influencer_feed.delete()
        creator_feed.delete()

        # comparison activity
        activity = love.create_activity()
        notification_feedly.add_love(love)

        # influencer feed
        assert influencer_feed.contains(activity)

        # creator feed
        creator_activity = copy.deepcopy(activity)
        creator_activity.extra_context['find'] = True
        assert creator_feed.contains(creator_activity)
Esempio n. 4
0
    def test_love(self):
        love = Love.objects.all()[:10][0]
        love.created_at = datetime.datetime.now()
        love.influencer_id = self.bogus_user.id
        influencer_feed = NotificationFeed(self.bogus_user.id)
        love.entity.created_by_id = self.bogus_user2.id
        creator_feed = NotificationFeed(self.bogus_user2.id)
        # we want to write two notifications
        # someone loved your find
        # someone loved your love
        notification_feedly = NotificationFeedly()
        # clean slate for testing
        influencer_feed.delete()
        creator_feed.delete()

        # comparison activity
        activity = love.create_activity()
        notification_feedly.add_love(love)

        # influencer feed
        assert influencer_feed.contains(activity)

        # creator feed
        creator_activity = copy.deepcopy(activity)
        creator_activity.extra_context['find'] = True
        assert creator_feed.contains(creator_activity)
Esempio n. 5
0
File: tests.py Progetto: etel/Feedly
    def test_add_love(self):
        # disable the follow notifications
        user_id = self.bogus_user.id
        self.set_setting(
            user_id, LoveVerb, dict(notify_mobile=False, enabled=False))

        love = Love.objects.all()[:10][0]
        love.created_at = datetime.datetime.now()
        love.influencer_id = user_id
        influencer_feed = NotificationFeed(user_id)
        love.entity.created_by_id = self.bogus_user2.id
        creator_feed = NotificationFeed(self.bogus_user2.id)
        # we want to write two notifications
        # someone loved your find
        # someone loved your love
        notification_feedly = NotificationFeedly()
        # clean slate for testing
        influencer_feed.delete()
        creator_feed.delete()

        # comparison activity
        activity = love.create_activity()
        notification_feedly.add_love(love)

        # influencer is equal to user_id and shouldnt contain the activity
        assert not influencer_feed.contains(activity)

        # creator feed should contain since the settings hasn't been disabled
        creator_activity = copy.deepcopy(activity)
        creator_activity.extra_context['find'] = True
        assert creator_feed.contains(creator_activity)
Esempio n. 6
0
    def test_follow_disabled(self):
        '''
        Verify that follows don't show up when you disable them in the settings
        '''
        from user.models import UserNotificationSetting
        # disable the follow notifications
        user_id = self.bogus_user.id
        self.set_setting(user_id, FollowVerb,
                         dict(notify_mobile=False, enabled=False))

        # verify that we disabled
        enabled = UserNotificationSetting.objects.enabled_for(
            user_id, FollowVerb)
        self.assertFalse(enabled)

        notification_feedly = NotificationFeedly()
        follows = Follow.objects.all()[:10]

        # clear the feed
        notification_feed = NotificationFeed(user_id)
        notification_feed.delete()

        # make sure that notifications for follows don't show up
        for follow in follows:
            follow.user_id = self.bogus_user2.id
            follow.target_id = user_id
            follow.created_at = datetime.datetime.now()
            activity = follow.create_activity()
            feed = notification_feedly._follow(follow)
            if feed:
                assert not feed.contains(activity)

        # the count should be zero
        self.assertEqual(notification_feed.count_unseen(), 0)
Esempio n. 7
0
    def test_add_to_list(self):
        notification_feedly = NotificationFeedly()
        notification_feed = NotificationFeed(self.bogus_user.id)
        list_items = ListItem.objects.all()[:1]

        for list_item in list_items:
            list_item.entity.created_by_id = self.bogus_user.id
            notification_feedly.add_to_list(list_item)
            activity = list_item.create_activity()

        assert notification_feed.contains(activity)
Esempio n. 8
0
    def test_add_to_list(self):
        notification_feedly = NotificationFeedly()
        notification_feed = NotificationFeed(self.bogus_user.id)
        list_items = ListItem.objects.all()[:1]

        for list_item in list_items:
            list_item.entity.created_by_id = self.bogus_user.id
            notification_feedly.add_to_list(list_item)
            activity = list_item.create_activity()

        assert notification_feed.contains(activity)
Esempio n. 9
0
    def test_performance(self):
        '''
        Test the performance of the feedly system for multiple add_loves
        '''
        start = datetime.datetime.now()
        notification_feedly = NotificationFeedly()

        loves = Love.objects.all()[:10]
        print loves.count()
        for love in loves:
            # run without the task
            notification_feedly._add_love(love)
        end = datetime.datetime.now()
        print end - start
Esempio n. 10
0
    def test_performance(self):
        '''
        Test the performance of the feedly system for multiple add_loves
        '''
        start = datetime.datetime.now()
        notification_feedly = NotificationFeedly()

        loves = Love.objects.all()[:10]
        print loves.count()
        for love in loves:
            # run without the task
            notification_feedly._add_love(love)
        end = datetime.datetime.now()
        print end - start
Esempio n. 11
0
    def test_follow(self):
        notification_feedly = NotificationFeedly()
        follows = Follow.objects.all()[:10]

        notification_feed = NotificationFeed(self.bogus_user.id)
        notification_feed.delete()

        for follow in follows:
            follow.user_id = self.bogus_user2.id
            follow.target_id = self.bogus_user.id
            follow.created_at = datetime.datetime.now()
            activity = follow.create_activity()
            feed = notification_feedly._follow(follow)
            assert feed.contains(activity)

        # influencer feed
        self.assertEqual(notification_feed.count_unseen(), 1)
Esempio n. 12
0
    def test_follow(self):
        notification_feedly = NotificationFeedly()
        follows = Follow.objects.all()[:10]

        notification_feed = NotificationFeed(self.bogus_user.id)
        notification_feed.delete()

        for follow in follows:
            follow.user_id = self.bogus_user2.id
            follow.target_id = self.bogus_user.id
            follow.created_at = datetime.datetime.now()
            activity = follow.create_activity()
            feed = notification_feedly._follow(follow)
            assert feed.contains(activity)

        # influencer feed
        self.assertEqual(notification_feed.count_unseen(), 1)
Esempio n. 13
0
    def test_duplicates(self):
        '''
        The task system can often attempt to duplicate an insert
        This should raise an error to prevent weird data
        '''
        notification_feedly = NotificationFeedly()
        notification_feed = NotificationFeed(self.bogus_user.id)
        notification_feed.delete()

        love = Love.objects.all()[:10][0]

        for x in range(3):
            love.influencer_id = self.bogus_user.id
            notification_feedly.add_love(love)

        for aggregated in notification_feed[:notification_feed.max_length]:
            activity_count = aggregated.activity_count
            self.assertEqual(activity_count, 1)
Esempio n. 14
0
    def test_duplicates(self):
        '''
        The task system can often attempt to duplicate an insert
        This should raise an error to prevent weird data
        '''
        notification_feedly = NotificationFeedly()
        notification_feed = NotificationFeed(self.bogus_user.id)
        notification_feed.delete()

        love = Love.objects.all()[:10][0]

        for x in range(3):
            love.influencer_id = self.bogus_user.id
            notification_feedly.add_love(love)

        for aggregated in notification_feed[:notification_feed.max_length]:
            activity_count = aggregated.activity_count
            self.assertEqual(activity_count, 1)
Esempio n. 15
0
    def test_duplicate_love_unlove(self):
        '''
        Test to verify that we dont end up with multiple notifications
        When users love and unlove the same data
        '''
        notification_feedly = NotificationFeedly()
        notification_feed = NotificationFeed(self.bogus_user.id)
        notification_feed.delete()

        love = Love.objects.all()[:10][0]

        for x in range(3):
            love.id = x
            love.influencer_id = self.bogus_user.id
            notification_feedly.add_love(love)

        for aggregated in notification_feed[:notification_feed.max_length]:
            activity_count = aggregated.activity_count
            self.assertEqual(activity_count, 1)
Esempio n. 16
0
    def test_duplicate_love_unlove(self):
        '''
        Test to verify that we dont end up with multiple notifications
        When users love and unlove the same data
        '''
        notification_feedly = NotificationFeedly()
        notification_feed = NotificationFeed(self.bogus_user.id)
        notification_feed.delete()

        love = Love.objects.all()[:10][0]

        for x in range(3):
            love.id = x
            love.influencer_id = self.bogus_user.id
            notification_feedly.add_love(love)

        for aggregated in notification_feed[:notification_feed.max_length]:
            activity_count = aggregated.activity_count
            self.assertEqual(activity_count, 1)
Esempio n. 17
0
def notification_follow(follow):
    from feedly.feed_managers.notification_feedly import NotificationFeedly
    feedly = NotificationFeedly()
    feedly._follow(follow)
Esempio n. 18
0
def notification_follow(follow):
    from feedly.feed_managers.notification_feedly import NotificationFeedly
    feedly = NotificationFeedly()
    feedly._follow(follow)
Esempio n. 19
0
def notification_add_love(love):
    from feedly.feed_managers.notification_feedly import NotificationFeedly
    feedly = NotificationFeedly()
    feedly._add_love(love)
Esempio n. 20
0
def notification_add_to_list(list_item):
    from feedly.feed_managers.notification_feedly import NotificationFeedly
    feedly = NotificationFeedly()
    feedly._add_to_list(list_item)
Esempio n. 21
0
def notification_add_to_list(list_item):
    from feedly.feed_managers.notification_feedly import NotificationFeedly
    feedly = NotificationFeedly()
    feedly._add_to_list(list_item)
Esempio n. 22
0
def notification_add_love(love):
    from feedly.feed_managers.notification_feedly import NotificationFeedly
    feedly = NotificationFeedly()
    feedly._add_love(love)