Skip to content

Commit c528d4e

Browse files
committed
Fix payload format.
1 parent 7316445 commit c528d4e

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/handlers/me/articles/like/create/me_articles_like_create.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,11 @@ def __post_tweet(self, user_id, title, tags):
152152
if tags:
153153
hash_tags_str += '\n#' + ' #'.join(tags)
154154
# tweet 文
155-
payload = \
156-
f"{title}\nhttps://{os.environ['DOMAIN']}/{user_id}/articles/{self.event['pathParameters']['article_id']}"\
157-
+ hash_tags_str
155+
payload = {
156+
"text": f"{title}\n"
157+
f"https://{os.environ['DOMAIN']}/{user_id}/articles/{self.event['pathParameters']['article_id']}" +
158+
hash_tags_str
159+
}
158160
# tweet 実施
159161
twitter_util = TwitterUtil(
160162
consumer_key=os.environ['TWITTER_APP_CONSUMER_KEY'],

tests/handlers/me/articles/like/create/test_me_articles_like_create.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ def test_main_ok_exist_article_id(self):
150150
response = article_liked_user.main()
151151
args, _ = mock_lib.return_value.post_tweet.call_args
152152
self.assertTrue(mock_lib.return_value.post_tweet.called)
153-
self.assertEqual(args[0], 'title1\nhttps://dummy/article_user_id_00/articles/testid000000\n#aaa #bbb #ccc #あいうえお')
153+
self.assertEqual(
154+
args[0],
155+
{'text': 'title1\nhttps://dummy/article_user_id_00/articles/testid000000\n#aaa #bbb #ccc #あいうえお'}
156+
)
154157

155158
article_liked_user_after = article_liked_user_table.scan()['Items']
156159
unread_notification_manager_after = unread_notification_manager_table.scan()['Items']
@@ -266,7 +269,7 @@ def test_main_with_updating_notification(self):
266269
response = article_liked_user.main()
267270
args, _ = mock_lib.return_value.post_tweet.call_args
268271
self.assertTrue(mock_lib.return_value.post_tweet.called)
269-
self.assertEqual(args[0], 'title3_updated\nhttps://dummy/article_user_id_02/articles/testid000002')
272+
self.assertEqual(args[0], {'text': 'title3_updated\nhttps://dummy/article_user_id_02/articles/testid000002'})
270273

271274
notification_after = notification_table.scan()['Items']
272275

0 commit comments

Comments
 (0)