예제 #1
0
def delete_comment(comment_id):
    try:
        args = {
            "user_id" : current_user.id,
            "comment_id": comment_id
        }
        Comment.delete_comment(**args)
        return redirect(request.referrer)
    except Exception as e:
        abort(400)
예제 #2
0
    def test_delete_comment_by_post_author(self):
        args={
            "user_id": 2,
            "comment_id": 10,
        }

        Comment.delete_comment(**args)

        comment = DBComment.get_by_id(10)
        self.assertIsNone(comment)
예제 #3
0
    def test_delete_comment_ideal_case(self):
        args={
            "user_id": 2,
            "comment_id": 1,
        }

        Comment.delete_comment(**args)

        comment = DBComment.get_by_id(1)
        self.assertIsNone(comment)
예제 #4
0
    def test_delete_others_comment(self):
        args={
            "user_id": 2,
            "comment_id": 2,
        }

        try:
            Comment.delete_comment(**args)
            self.fail("Expect AccessDeniedError")
        except AccessDeniedError:
            pass
예제 #5
0
    def test_delete_comment_with_not_exist_comment(self):
        args={
            "user_id": 2,
            "comment_id": 200,
        }

        try:
            Comment.delete_comment(**args)
            self.fail("Expect CommentNotFoundError")
        except CommentNotFoundError:
            pass
예제 #6
0
    def test_delete_comment_invalid_comment_id(self):
        args={
            "user_id": 2,
            "comment_id": -2,
        }

        try:
            Comment.delete_comment(**args)
            self.fail("Expect InvalidFieldError")
        except InvalidFieldError:
            pass