Ejemplo n.º 1
0
    def test_get_user_following(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(user1['id'],user2['id'])
        backend.follow_user(user1['id'],user3['id'])

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

        count = backend.get_user_following_count(user1['id'])
        assert count == 2
Ejemplo n.º 2
0
    def test_get_user_following(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(user1['id'], user2['id'])
        backend.follow_user(user1['id'], user3['id'])

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

        count = backend.get_user_following_count(user1['id'])
        assert count == 2
Ejemplo n.º 3
0
    def get(self,user_id):
        try:
            page = int(request.values.get('page'))
        except:
            page = 1

        limit = 50
        offset = (page-1) * 50

        following_users = backend.get_user_following(user_id,limit=limit,
                                offset=offset)

        curr_user = backend.get_user_by_uid(g.ukey)

        fids = [u['id'] for u in following_users]
        fdict = backend.is_following_user(curr_user['id'],fids)
        for fu in following_users:
            fu['follower_count'] = backend.get_user_follower_count(fu['id'])
            fu['is_follow'] = fdict.get(fu['id']) or False
        count = backend.get_user_following_count(user_id)
        total_page = (count + 49) / 50
        return jsonify(users=following_users,page=page,total_page=total_page)
Ejemplo n.º 4
0
    def get(self, user_id):
        try:
            page = int(request.values.get('page'))
        except:
            page = 1

        limit = 50
        offset = (page - 1) * 50

        following_users = backend.get_user_following(user_id,
                                                     limit=limit,
                                                     offset=offset)

        curr_user = backend.get_user_by_uid(g.ukey)

        fids = [u['id'] for u in following_users]
        fdict = backend.is_following_user(curr_user['id'], fids)
        for fu in following_users:
            fu['follower_count'] = backend.get_user_follower_count(fu['id'])
            fu['is_follow'] = fdict.get(fu['id']) or False
        count = backend.get_user_following_count(user_id)
        total_page = (count + 49) / 50
        return jsonify(users=following_users, page=page, total_page=total_page)