def test_creation(self): response = comment_request_impl(self.args) assert response['success'] is True recently_created_comment = comment_from_id(response['data']['id']) assert recently_created_comment in self.post.comments db.session.delete(recently_created_comment) db.session.commit()
def delete_comment_request_impl(args): try: author = user_from_token(args['token']) comment = comment_from_id(args['comment_id']) if author.id != comment.user_id: raise NoPermissionException() comment.active = False db.session.commit() return Response(True, "Comment Deleted", None).output() except Exception as exception: return Response(False, str(exception), None).output()