@@ -170,6 +170,45 @@ def test_main_ok_already_commented_by_myself(self):
170170 self .assertEqual (len (comment_after ) - len (comment_before ), 1 )
171171 self .assertIsNotNone (comment )
172172
173+ @patch ('me_articles_comments_create.MeArticlesCommentsCreate._MeArticlesCommentsCreate__generate_comment_id' ,
174+ MagicMock (return_value = 'PIYOPIYO' ))
175+ def test_main_ok_with_adding_comment_on_own_article (self ):
176+ params = {
177+ 'pathParameters' : {
178+ 'article_id' : 'publicId0001'
179+ },
180+ 'body' : {
181+ 'text' : 'A' * 400 ,
182+ },
183+ 'requestContext' : {
184+ 'authorizer' : {
185+ 'claims' : {
186+ 'cognito:username' : 'article_user01'
187+ }
188+ }
189+ }
190+ }
191+
192+ params ['body' ] = json .dumps (params ['body' ])
193+
194+ comment_before = self .comment_table .scan ()['Items' ]
195+ notification_before = self .notification_table .scan ()['Items' ]
196+ unread_notification_manager_before = self .unread_notification_manager_table .scan ()['Items' ]
197+
198+ response = MeArticlesCommentsCreate (params , {}, self .dynamodb ).main ()
199+
200+ comment_after = self .comment_table .scan ()['Items' ]
201+ notification_after = self .notification_table .scan ()['Items' ]
202+ unread_notification_manager_after = self .unread_notification_manager_table .scan ()['Items' ]
203+
204+ comment = self .comment_table .get_item (Key = {'comment_id' : 'PIYOPIYO' }).get ('Item' )
205+
206+ self .assertEqual (response ['statusCode' ], 200 )
207+ self .assertIsNotNone (comment )
208+ self .assertEqual (len (comment_after ) - len (comment_before ), 1 )
209+ self .assertEqual (len (notification_after ) - len (notification_before ), 0 )
210+ self .assertEqual (len (unread_notification_manager_after ) - len (unread_notification_manager_before ), 0 )
211+
173212 def test_call_validate_comment_existence (self ):
174213 params = {
175214 'pathParameters' : {
0 commit comments