Beispiel #1
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)
Beispiel #2
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)
Beispiel #3
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)
Beispiel #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)
Beispiel #5
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)
Beispiel #6
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)
Beispiel #7
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)
Beispiel #8
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)