Skip to content

Commit d965d95

Browse files
committed
Return comment_id when comment created
1 parent 05a0ba0 commit d965d95

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/handlers/me/articles/comments/create/me_articles_comments_create.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# -*- coding: utf-8 -*-
2+
import json
23
import logging
34
import os
45
import traceback
@@ -66,7 +67,10 @@ def exec_main_proc(self):
6667
logging.fatal(err)
6768
traceback.print_exc()
6869
finally:
69-
return {'statusCode': 200}
70+
return {
71+
'statusCode': 200,
72+
'body': json.dumps({'comment_id': comment_id})
73+
}
7074

7175
def __create_comment_notification(self, article_info, comment_id, user_id):
7276
notification_table = self.dynamodb.Table(os.environ['NOTIFICATION_TABLE_NAME'])

tests/handlers/me/articles/comments/create/test_me_articles_comments_create.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def test_main_ok(self):
101101
unread_manager = self.unread_notification_manager_table.get_item(Key={'user_id': 'article_user01'}).get('Item')
102102

103103
self.assertEqual(response['statusCode'], 200)
104+
self.assertEqual(json.loads(response['body'])['comment_id'], 'HOGEHOGEHOGE')
104105
self.assertEqual(len(comment_after) - len(comment_before), 1)
105106
self.assertEqual(len(notification_after) - len(notification_before), 1)
106107
self.assertEqual(len(unread_notification_manager_after) - len(unread_notification_manager_before), 1)

0 commit comments

Comments
 (0)