-
Notifications
You must be signed in to change notification settings - Fork 857
Fix #1053 by changing request body format to params #1054
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
seratch
merged 1 commit into
slackapi:main
from
seratch:issue-1053-sequence-value-in-json
Jul 1, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import logging | ||
| import os | ||
| import time | ||
| import unittest | ||
|
|
||
| from integration_tests.env_variable_names import SLACK_SDK_TEST_BOT_TOKEN | ||
| from slack_sdk.web import WebClient | ||
|
|
||
|
|
||
| class TestWebClient(unittest.TestCase): | ||
| """Runs integration tests with real Slack API | ||
|
|
||
| https://github.com/slackapi/python-slack-sdk/issues/1053 | ||
| """ | ||
|
|
||
| def setUp(self): | ||
| self.logger = logging.getLogger(__name__) | ||
| self.bot_token = os.environ[SLACK_SDK_TEST_BOT_TOKEN] | ||
|
|
||
| def tearDown(self): | ||
| pass | ||
|
|
||
| def test_issue_1053(self): | ||
| client: WebClient = WebClient(token=self.bot_token) | ||
| self_user_id = client.auth_test()["user_id"] | ||
| channel_name = f"test-channel-{str(time.time()).replace('.', '-')}" | ||
| channel_id = None | ||
| try: | ||
| creation = client.conversations_create(name=channel_name) | ||
| self.assertIsNone(creation.get("error")) | ||
| channel_id = creation["channel"]["id"] | ||
| user_ids = [ | ||
| u["id"] | ||
| for u in client.users_list(limit=100)["members"] | ||
| if u["id"] not in {"USLACKBOT", self_user_id} | ||
| and u.get("is_bot", False) is False | ||
| and u.get("is_app_user", False) is False | ||
| and u.get("is_restricted", False) is False | ||
| and u.get("is_ultra_restricted", False) is False | ||
| and u.get("is_email_confirmed", False) is True | ||
| ] | ||
| invitations = client.conversations_invite( | ||
| channel=channel_id, users=user_ids | ||
| ) | ||
| self.assertIsNone(invitations.get("error")) | ||
| finally: | ||
| if channel_id is not None: | ||
| client.conversations_archive(channel=channel_id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -621,7 +621,7 @@ async def admin_users_session_getSettings( | |
| kwargs.update({"user_ids": ",".join(user_ids)}) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code currently works but the server-side may stop accepting this format in the future. That's the reason why we want to make the changes in this PR. |
||
| else: | ||
| kwargs.update({"user_ids": user_ids}) | ||
| return await self.api_call("admin.users.session.getSettings", json=kwargs) | ||
| return await self.api_call("admin.users.session.getSettings", params=kwargs) | ||
|
|
||
| async def admin_users_session_setSettings( | ||
| self, *, user_ids: Union[str, Sequence[str]], **kwargs | ||
|
|
@@ -636,7 +636,7 @@ async def admin_users_session_setSettings( | |
| kwargs.update({"user_ids": ",".join(user_ids)}) | ||
| else: | ||
| kwargs.update({"user_ids": user_ids}) | ||
| return await self.api_call("admin.users.session.setSettings", json=kwargs) | ||
| return await self.api_call("admin.users.session.setSettings", params=kwargs) | ||
|
|
||
| async def admin_users_session_clearSettings( | ||
| self, *, user_ids: Union[str, Sequence[str]], **kwargs | ||
|
|
@@ -651,7 +651,7 @@ async def admin_users_session_clearSettings( | |
| kwargs.update({"user_ids": ",".join(user_ids)}) | ||
| else: | ||
| kwargs.update({"user_ids": user_ids}) | ||
| return await self.api_call("admin.users.session.clearSettings", json=kwargs) | ||
| return await self.api_call("admin.users.session.clearSettings", params=kwargs) | ||
|
|
||
| async def admin_inviteRequests_approve( | ||
| self, *, invite_request_id: str, **kwargs | ||
|
|
@@ -815,7 +815,7 @@ async def admin_usergroups_addChannels( | |
| kwargs.update({"channel_ids": ",".join(channel_ids)}) | ||
| else: | ||
| kwargs.update({"channel_ids": channel_ids}) | ||
| return await self.api_call("admin.usergroups.addChannels", json=kwargs) | ||
| return await self.api_call("admin.usergroups.addChannels", params=kwargs) | ||
|
|
||
| async def admin_usergroups_addTeams( | ||
| self, *, usergroup_id: str, team_ids: Union[str, Sequence[str]], **kwargs | ||
|
|
@@ -833,7 +833,7 @@ async def admin_usergroups_addTeams( | |
| kwargs.update({"team_ids": ",".join(team_ids)}) | ||
| else: | ||
| kwargs.update({"team_ids": team_ids}) | ||
| return await self.api_call("admin.usergroups.addTeams", json=kwargs) | ||
| return await self.api_call("admin.usergroups.addTeams", params=kwargs) | ||
|
|
||
| async def admin_usergroups_listChannels( | ||
| self, *, usergroup_id: str, **kwargs | ||
|
|
@@ -860,7 +860,7 @@ async def admin_usergroups_removeChannels( | |
| kwargs.update({"channel_ids": ",".join(channel_ids)}) | ||
| else: | ||
| kwargs.update({"channel_ids": channel_ids}) | ||
| return await self.api_call("admin.usergroups.removeChannels", json=kwargs) | ||
| return await self.api_call("admin.usergroups.removeChannels", params=kwargs) | ||
|
|
||
| async def admin_users_assign( | ||
| self, *, team_id: str, user_id: str, **kwargs | ||
|
|
@@ -895,7 +895,7 @@ async def admin_users_invite( | |
| kwargs.update({"channel_ids": ",".join(channel_ids)}) | ||
| else: | ||
| kwargs.update({"channel_ids": channel_ids}) | ||
| return await self.api_call("admin.users.invite", json=kwargs) | ||
| return await self.api_call("admin.users.invite", params=kwargs) | ||
|
|
||
| async def admin_users_list(self, *, team_id: str, **kwargs) -> AsyncSlackResponse: | ||
| """List users on a workspace | ||
|
|
@@ -1461,7 +1461,7 @@ async def conversations_invite( | |
| kwargs.update({"users": ",".join(users)}) | ||
| else: | ||
| kwargs.update({"users": users}) | ||
| return await self.api_call("conversations.invite", json=kwargs) | ||
| return await self.api_call("conversations.invite", params=kwargs) | ||
|
|
||
| async def conversations_join(self, *, channel: str, **kwargs) -> AsyncSlackResponse: | ||
| """Joins an existing conversation. | ||
|
|
@@ -2081,7 +2081,7 @@ async def mpim_open( | |
| kwargs.update({"users": ",".join(users)}) | ||
| else: | ||
| kwargs.update({"users": users}) | ||
| return await self.api_call("mpim.open", json=kwargs) | ||
| return await self.api_call("mpim.open", params=kwargs) | ||
|
|
||
| async def mpim_replies( | ||
| self, *, channel: str, thread_ts: str, **kwargs | ||
|
|
@@ -2431,7 +2431,7 @@ async def usergroups_users_update( | |
| kwargs.update({"users": ",".join(users)}) | ||
| else: | ||
| kwargs.update({"users": users}) | ||
| return await self.api_call("usergroups.users.update", json=kwargs) | ||
| return await self.api_call("usergroups.users.update", params=kwargs) | ||
|
|
||
| async def users_conversations(self, **kwargs) -> AsyncSlackResponse: | ||
| """List conversations the calling user may access.""" | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid ratelimited errors with my test workspace (it has a very large number of channels)