Ejemplo n.º 1
0
    def test_get_latest_feed(self):
        user1 = backend.add_user('username01','photo_url01','weibo_id01')
        user2 = backend.add_user('username02','photo_url02','weibo_id02')
        user3 = backend.add_user('username03','photo_url03','weibo_id03') 
        user4 = backend.add_user('username04','photo_url04','weibo_id04')

        post1 = backend.add_post('title01',user1['id'],'video_url01',
                    pic_small='pic_small01')
        post2 = backend.add_post('title02',user2['id'],'video_url02',
                    pic_small='pic_small')
        post3 = backend.add_post('title03',user3['id'],'video_url03',
                    pic_small='pic_small03')
        post4 = backend.add_post('title04',user4['id'],'video_url04',
                    pic_small='pic_small04')

        backend.follow_user(user4['id'],user1['id'])
        backend.follow_user(user4['id'],user2['id'])
        

        ret = backend.get_latest_feed(user4['id'],limit=10,offset=0)
        assert len(ret) == 3

        backend.set_post(post3['id'],{'recommended':True})

        ret = backend.get_latest_feed(user4['id'],limit=10,offset=0)
        assert len(ret) == 4
Ejemplo n.º 2
0
    def test_is_following_user(self):
        user1 = backend.add_user('username01','photo_url01','weibo_id01')
        user2 = backend.add_user('username02','photo_url02','weibo_id02')

        backend.follow_user(user1['id'],user2['id'])
        ret = backend.is_following_user(user1['id'],user2['id'])
        assert ret == True
Ejemplo n.º 3
0
    def test_is_following_user(self):
        user1 = backend.add_user('username01', 'photo_url01', 'weibo_id01')
        user2 = backend.add_user('username02', 'photo_url02', 'weibo_id02')

        backend.follow_user(user1['id'], user2['id'])
        ret = backend.is_following_user(user1['id'], user2['id'])
        assert ret == True
Ejemplo n.º 4
0
    def test_get_latest_feed(self):
        user1 = backend.add_user('username01', 'photo_url01', 'weibo_id01')
        user2 = backend.add_user('username02', 'photo_url02', 'weibo_id02')
        user3 = backend.add_user('username03', 'photo_url03', 'weibo_id03')
        user4 = backend.add_user('username04', 'photo_url04', 'weibo_id04')

        post1 = backend.add_post('title01',
                                 user1['id'],
                                 'video_url01',
                                 pic_small='pic_small01')
        post2 = backend.add_post('title02',
                                 user2['id'],
                                 'video_url02',
                                 pic_small='pic_small')
        post3 = backend.add_post('title03',
                                 user3['id'],
                                 'video_url03',
                                 pic_small='pic_small03')
        post4 = backend.add_post('title04',
                                 user4['id'],
                                 'video_url04',
                                 pic_small='pic_small04')

        backend.follow_user(user4['id'], user1['id'])
        backend.follow_user(user4['id'], user2['id'])

        ret = backend.get_latest_feed(user4['id'], limit=10, offset=0)
        assert len(ret) == 3

        backend.set_post(post3['id'], {'recommended': True})

        ret = backend.get_latest_feed(user4['id'], limit=10, offset=0)
        assert len(ret) == 4
Ejemplo n.º 5
0
    def test_feeds_view(self):
        user1 = backend.add_user('username01','photo_url01','weibo_id01')
        user2 = backend.add_user('username02','photo_url02','weibo_id02')
        user3 = backend.add_user('username03','photo_url03','weibo_id03') 
        user4 = backend.add_user('username04','photo_url04','weibo_id04')

        post1 = backend.add_post('title01',user1['id'],'video_url01',
                    pic_small='pic_small01')
        post2 = backend.add_post('title02',user2['id'],'video_url02',
                    pic_small='pic_small')
        post3 = backend.add_post('title03',user3['id'],'video_url03',
                    pic_small='pic_small03')
        post4 = backend.add_post('title04',user4['id'],'video_url04',
                    pic_small='pic_small04')

        backend.follow_user(user4['id'],user1['id'])
        backend.follow_user(user4['id'],user2['id'])

        headers = self.generate_header('weibo_id04')

        resp = self.client.get('/feeds/%d' % user4['id'],headers=headers)
        ret = json.loads(resp.data)
        assert len(ret['results']) == 3


        backend.set_post(post3['id'],{'recommended':True})

        resp = self.client.get('/feeds/%d'% user4['id'],headers=headers)
        ret = json.loads(resp.data)

        assert len(ret['results']) == 4
Ejemplo n.º 6
0
    def test_get_user_follower(self):
        user1 = backend.add_user('username01','photo_url01','weibo_id01')
        user2 = backend.add_user('username02','photo_url02','weibo_id02')
        user3 = backend.add_user('username03','photo_url03','weibo_id03')

        backend.follow_user(user2['id'],user1['id'])
        backend.follow_user(user3['id'],user1['id'])

        users = backend.get_user_follower(user1['id'])
        assert len(users) == 2
        
        count = backend.get_user_follower_count(user1['id'])
        assert count == 2
Ejemplo n.º 7
0
    def test_get_user_follower(self):
        user1 = backend.add_user('username01', 'photo_url01', 'weibo_id01')
        user2 = backend.add_user('username02', 'photo_url02', 'weibo_id02')
        user3 = backend.add_user('username03', 'photo_url03', 'weibo_id03')

        backend.follow_user(user2['id'], user1['id'])
        backend.follow_user(user3['id'], user1['id'])

        users = backend.get_user_follower(user1['id'])
        assert len(users) == 2

        count = backend.get_user_follower_count(user1['id'])
        assert count == 2
Ejemplo n.º 8
0
 def post(self):
     '''关注用户'''
     data = UserFollowSchema().deserialize(request.json)
     from_id = authutil.get_user_id(g.ukey)
     for uid in data['user_ids']:
         try:
             backend.follow_user(from_id, uid)
             backend.add_activity({
                 'from_id': from_id,
                 'to_id': uid,
                 'atype': 'follow'
             })
         except BackendError, ex:
             pass
Ejemplo n.º 9
0
 def post(self):
     '''关注用户'''
     data = UserFollowSchema().deserialize(request.json)
     from_id = authutil.get_user_id(g.ukey)
     for uid in data['user_ids']:
         try:
             backend.follow_user(from_id,uid)
             backend.add_activity({
                     'from_id':from_id,
                     'to_id':uid,
                     'atype':'follow'
                 })
         except BackendError,ex:
             pass
Ejemplo n.º 10
0
    def test_feeds_view(self):
        user1 = backend.add_user('username01', 'photo_url01', 'weibo_id01')
        user2 = backend.add_user('username02', 'photo_url02', 'weibo_id02')
        user3 = backend.add_user('username03', 'photo_url03', 'weibo_id03')
        user4 = backend.add_user('username04', 'photo_url04', 'weibo_id04')

        post1 = backend.add_post('title01',
                                 user1['id'],
                                 'video_url01',
                                 pic_small='pic_small01')
        post2 = backend.add_post('title02',
                                 user2['id'],
                                 'video_url02',
                                 pic_small='pic_small')
        post3 = backend.add_post('title03',
                                 user3['id'],
                                 'video_url03',
                                 pic_small='pic_small03')
        post4 = backend.add_post('title04',
                                 user4['id'],
                                 'video_url04',
                                 pic_small='pic_small04')

        backend.follow_user(user4['id'], user1['id'])
        backend.follow_user(user4['id'], user2['id'])

        headers = self.generate_header('weibo_id04')

        resp = self.client.get('/feeds/%d' % user4['id'], headers=headers)
        ret = json.loads(resp.data)
        assert len(ret['results']) == 3

        backend.set_post(post3['id'], {'recommended': True})

        resp = self.client.get('/feeds/%d' % user4['id'], headers=headers)
        ret = json.loads(resp.data)

        assert len(ret['results']) == 4