def update_comment(comment_id, auth_info): form = {key: request.form.get(key) for key in request.form.keys()} args = {} args.update(auth_info) args.update(form) updated_comment = CommentController.update_comment(comment_id, args) return ResponseOK(updated_comment)
def create_comment(doc_id, auth_info): form = {key: request.form.get(key) for key in request.form.keys()} args = {} args.update(auth_info) args.update(form) comment = CommentController.create_comment(doc_id, args) return ResponseCreated(comment)
def test_get_comments(self): print("get comments") expected_response = [{ 'description': 'ok_1', 'id': 1, 'user_id': 1, 'doc_id': 1, 'date': FAKE_TIME }] assert expected_response == CommentController.get_comments(1)
def test_create_comment_2(self, patch_datetime_now): print("Create a comment") expected_response = { 'id': 2, 'user_id': 1, 'doc_id': 1, 'description': 'ok_2', 'date': FAKE_TIME } assert expected_response == CommentController.create_comment(1, { 'user_id': 1, 'description': 'ok_2' })
def test_delete_comment(self): print("delete a comment") expected_response = { 'id': 2, 'user_id': 1, 'doc_id': 1, 'description': 'ok_2', 'date': FAKE_TIME } assert expected_response == CommentController.delete_comment(2, { 'user_id': 1, "role": { 'label': 'admin' } })
def test_update_comment(self): print("update a comment") expected_response = { 'doc_id': 1, 'user_id': 1, 'description': 'ok_1', 'id': 1, 'date': FAKE_TIME } assert expected_response == CommentController.update_comment(1, { 'id': 1, 'user_id': 1, "role": { 'label': 'admin' }, 'description': 'ok_1' })
def delete_comment(comment_id, auth_info): deleted_comment = CommentController.delete_comment(comment_id, auth_info) return ResponseOK(deleted_comment)
def get_comment_by_id(comment_id): comment = CommentController.get_comment(comment_id) return ResponseOK(comment)
def get_comment(doc_id, auth_info): DocController.get_document_by_id(doc_id, auth_info) comments = CommentController.get_comments(doc_id) return ResponseOK(comments)