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 test_dispatch_post_to_followers(self): user_to_follow = User.create('anonymous','password') me = User.create(self.params['username'],self.params['password']) me.follow(user_to_follow) Post.create(user_to_follow,self.params['post']) self.assertEqual(1,len(me.timeline())) self.assertEqual(1,len(me.timeline()))
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 test_dispatch_post_to_followers(self): user_to_follow = User.create('anonymous', 'password') me = User.create(self.params['username'], self.params['password']) me.follow(user_to_follow) Post.create(user_to_follow, self.params['post']) self.assertEqual(1, len(me.timeline())) self.assertEqual(1, len(me.timeline()))
def post(user): try: content = bottle.request.POST['content'] Post.create(user, content) except KeyError, e: pass
def test_create_post_with_mention(self): user = User.create(self.params['username'],self.params['password']) content_with_mention = self.params['post'] + '@' + self.params['username'] Post.create(user,content_with_mention) self.assertEqual(1,len(user.mentions()))
def test_create_post(self): user = User.create(self.params['username'],self.params['password']) Post.create(user,self.params['post']) self.assertEqual(1,len(user.posts())) self.assertEqual(1,user.posts()[0].id) self.assertEqual(self.params['post'],user.posts()[0].content)
def test_create_post_with_mention(self): user = User.create(self.params['username'], self.params['password']) content_with_mention = self.params['post'] + '@' + self.params[ 'username'] Post.create(user, content_with_mention) self.assertEqual(1, len(user.mentions()))
def test_create_post(self): user = User.create(self.params['username'], self.params['password']) Post.create(user, self.params['post']) self.assertEqual(1, len(user.posts())) self.assertEqual(1, user.posts()[0].id) self.assertEqual(self.params['post'], user.posts()[0].content)
def post(user): content = bottle.request.POST['content'] Post.create(user, content) bottle.redirect('/home')
def post(user): try: content = bottle.request.POST['content'] Post.create(user, content) except KeyError, e: pass
def post(user): content = bottle.request.POST['content'] Post.create(user, content) bottle.redirect('/home')