Beispiel #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
Beispiel #2
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
Beispiel #3
0
 def delete(self, post_id):
     post = backend.get_post(post_id)
     curr_id = authutil.get_user_id(g.ukey)
     if post["author_id"] != curr_id:
         return jsonify(error="forbid")
     try:
         backend.set_post(post_id, {"show": "deleted_by_user"})
     except BackendError, ex:
         abort(501)
Beispiel #4
0
    def test_add_post(self):
        user = backend.add_user('username','photo_url','weibo_id')
        post = backend.add_post('title',user['id'],'video_url',
                pic_small='pic_small')
        
        assert post['title'] == 'title'

        post = backend.set_post(post['id'],{'title':'title2'})
        assert post['title'] == 'title2'
Beispiel #5
0
 def put(self, post_id):
     data = UpdatePostSchema().deserialize(request.json)
     try:
         backend.set_post(post_id, data)
     except BackendError, ex:
         abort(501)