def test_get_post_item(self): user = backend.add_user('user02', '*****@*****.**', 'pass02') post1 = backend.add_post('title01', user['id'], content='content01') item1 = Item(post_id=post1['id'], title='title01', content='content01') item2 = Item(post_id=post1['id'], title='title02', content='content02') item3 = Item(post_id=post1['id'], title='title03', content='content03') db.session.add(item1) db.session.add(item2) db.session.add(item3) db.session.commit() items = backend.get_post_item(post1['id']) assert len(items) == 3 count = backend.get_post_item_count(post1['id']) assert count == 3
def test_get_post_item(self): user = backend.add_user('user02','*****@*****.**','pass02') post1 = backend.add_post('title01',user['id'],content='content01') item1 = Item(post_id=post1['id'],title='title01',content='content01') item2 = Item(post_id=post1['id'],title='title02',content='content02') item3 = Item(post_id=post1['id'],title='title03',content='content03') db.session.add(item1) db.session.add(item2) db.session.add(item3) db.session.commit() items = backend.get_post_item(post1['id']) assert len(items) == 3 count = backend.get_post_item_count(post1['id']) assert count == 3
post = backend.get_post(post_id) except BackendError,ex: abort(404) try: page = int(request.values.get('page','1')) except ValueError: page = 1 if page <= 0: page = 1 limit = 50 offset = (page - 1) * 50 items = backend.get_post_item(post_id,limit=limit,offset=offset) item_count = len(items) if len(items) <= 50 else \ backend.get_post_item_count(post_id) return render_template('site/post_one.html', post=post, items=items, item_count=item_count) @instance.route('/post/<int:post_id>/edit',methods=('GET','POST')) @user_required def post_edit(post_id): post = backend.get_post(post_id) if post['author_id'] != g.user_id: abort(403)