def test_spam(self): comment1 = comments.find(self.comment_id) comments.spam(comment1) comment2 = comments.find(self.comment_id) self.assertIsNot(comment1, comment2) self.assertEqual(comment1.review, 'forbidden') self.assertEqual(comment2.review, 'forbidden')
def test_approve(self): comment1 = comments.find(self.comment_id) comments.approve(comment1) comment2 = comments.find(self.comment_id) self.assertIsNot(comment1, comment2) self.assertEqual(comment1.review, 'approved') self.assertEqual(comment2.review, 'approved')
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)
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_new_comment(self): video = videos.find(self.video_id) user = users.find(self.user_id) text = 'This is a new comment from {0}'.format(repr(self)) time = float(video.duration) / 3 comment1 = comments.new_comment(video, user, text, time) comment2 = comments.find(comment1.sysid) removed = self.database.comments.remove(ObjectId(comment1.sysid)) self.assertIsNot(comment1, comment2) self.assertEqual(comment1.text, text) self.assertEqual(comment2.text, text) self.assertEqual(removed['n'], 1)
def test_find(self): comment = comments.find(self.comment_id) self.assertIsNotNone(comment)