def test_post_find_by_id(self): user = User.create(self.params['username'],self.params['password']) Post.create(user,self.params['post']) post_found = Post.find_by_id(1) self.assertEqual(1,post_found.id) self.assertEqual(user.id,int(post_found.user_id)) #shouldn't need int() self.assertEqual(self.params['username'],post_found.user.username)
def status(name,id): post = Post.find_by_id(id) if post: if post.user.username == name: return bottle.template('single',username=post.user.username,tweet=post,page='single', logged=user_is_logged()) return bottle.HTTPError(code=404,message='tweet not found')
def status(name, id): post = Post.find_by_id(id) if post: if post.user.username == name: return bottle.template('single', username=post.user.username, tweet=post, page='single', logged=user_is_logged()) return bottle.HTTPError(code=404, message='tweet not found')
def status(auth, name,id): post = Post.find_by_id(id) if post: if post.user.username == name: if auth != None: return bottle.template('single',username=post.user.username,tweet=post,page='single', logged=user_is_logged(),viewer=auth.username) else: return bottle.template('single',username=post.user.username,tweet=post,page='single', logged=user_is_logged(),viewer="") return bottle.HTTPError(code=404,message='tweet not found')
def status(name, id): user = User.find_by_username(name) if user: post = Post.find_by_id(user.id + ':' + id) else: post = None if post: if post.user.username == name: return bottle.template('single', username=post.user.username, tweet=post, page='single', logged=user_is_logged()) return bottle.HTTPError(code=404, message='tweet not found')
def status(auth, name, id): post = Post.find_by_id(id) if post: if post.user.username == name: if auth != None: return bottle.template('single', username=post.user.username, tweet=post, page='single', logged=user_is_logged(), viewer=auth.username) else: return bottle.template('single', username=post.user.username, tweet=post, page='single', logged=user_is_logged(), viewer="") return bottle.HTTPError(code=404, message='tweet not found')