@@ -73,6 +73,14 @@ def setUp(self):
7373 'status' : 'public' ,
7474 'user_id' : 'article_user_id_02' ,
7575 'sort_key' : 1520150272000002
76+ },
77+ {
78+ 'article_id' : 'testid000003' ,
79+ 'title' : '123456789012345678901234567890123456789012345678901234567890' ,
80+ 'status' : 'public' ,
81+ 'user_id' : 'article_user_id_03' ,
82+ 'tags' : ['a1234567890' , 'b1234567890' , 'c1234567890' , 'd1234567890' , 'e1234567890' ],
83+ 'sort_key' : 1520150272000003
7684 }
7785 ]
7886 TestsUtil .create_table (
@@ -292,14 +300,15 @@ def test_main_with_updating_notification(self):
292300
293301 @patch ('time.time' , MagicMock (return_value = 1520150272.000015 ))
294302 def test_main_ok_with_self_liked_user (self ):
303+ settings .LIKED_TWEET_COUNT = 1
295304 params = {
296305 'pathParameters' : {
297- 'article_id' : self .article_info_table_items [2 ]['article_id' ]
306+ 'article_id' : self .article_info_table_items [3 ]['article_id' ]
298307 },
299308 'requestContext' : {
300309 'authorizer' : {
301310 'claims' : {
302- 'cognito:username' : self .article_info_table_items [2 ]['user_id' ],
311+ 'cognito:username' : self .article_info_table_items [3 ]['user_id' ],
303312 'custom:private_eth_address' : '0x1234567890123456789012345678901234567890' ,
304313 'phone_number_verified' : 'true' ,
305314 'email_verified' : 'true'
@@ -315,7 +324,19 @@ def test_main_ok_with_self_liked_user(self):
315324 notification_before = notification_table .scan ()['Items' ]
316325 unread_notification_manager_before = unread_notification_manager_table .scan ()['Items' ]
317326
318- response = MeArticlesLikeCreate (event = params , context = {}, dynamodb = self .dynamodb ).main ()
327+ mock_lib = MagicMock ()
328+ with patch ('me_articles_like_create.TwitterUtil' , mock_lib ):
329+ response = MeArticlesLikeCreate (event = params , context = {}, dynamodb = self .dynamodb ).main ()
330+ args , _ = mock_lib .return_value .post_tweet .call_args
331+ self .assertTrue (mock_lib .return_value .post_tweet .called )
332+ self .assertEqual (
333+ args [0 ],
334+ {
335+ 'text' : '12345678901234567890123456789012345678901234567890...\n '
336+ 'https://dummy/article_user_id_03/articles/testid000003\n '
337+ '#a1234567890 #b1234567890 #c1234567890 #d1234567890'
338+ }
339+ )
319340
320341 notification_after = notification_table .scan ()['Items' ]
321342 unread_notification_manager_after = unread_notification_manager_table .scan ()['Items' ]
0 commit comments