def test_like(self):
     user = users.find(self.user_id)
     comment1 = comments.find(self.comment_id)
     likes = comment1.likes
     comments.like(comment1, user)
     comment2 = comments.find(self.comment_id)
     self.assertIsNot(comment1, comment2)
     self.assertEqual(comment1.likes, likes+1)
     self.assertEqual(comment2.likes, likes+1)
Exemplo n.º 2
0
def append_like():
    video_id = request.json['video_id']
    comment_id = request.json['comment_id']
    user = users.current()
    comment = comments.find(comment_id)
    if not user.anonymous:
        comments.like(comment, user)
    comment = comments.find(comment_id)
    return jsonify(likes=comment.likes)
 def test_unlike(self):
     user = users.find(self.user_id)
     comment1 = comments.find(self.comment_id)
     comments.like(comment1, user)
     comment2 = comments.find(self.comment_id)
     likes = comment2.likes
     comments.unlike(comment2, user)
     comment3 = comments.find(self.comment_id)
     self.assertIsNot(comment2, comment3)
     self.assertEqual(comment2.likes, likes-1)
     self.assertEqual(comment3.likes, likes-1)
 def test_like_comment(self):
     self._insert_comments(10)
     coms = comments.for_screening(self.video, self.user)
     forlike = coms[5]
     comments.like(forlike, self.user)
     coms = comments.for_screening(self.video, self.user)
     liked = coms[5]
     comments.unlike(forlike, self.user)
     coms = comments.for_screening(self.video, self.user)
     unliked = coms[5]
     notliked = coms[6]
     self.assertTrue(liked.liked)
     self.assertFalse(unliked.liked)
     self.assertFalse(notliked.liked)