Skip to content

Commit

Permalink
Merge pull request #706 from seratch/issue-705-no-param-pagination
Browse files Browse the repository at this point in the history
Fix #705 by modifying SlackResponse to consider None value in dict
  • Loading branch information
seratch committed May 28, 2020
2 parents 59c8923 + f0bb96c commit 9a261bb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 5 additions & 3 deletions slack/web/slack_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,11 @@ def __next__(self):
if self._iteration == 1:
return self
if self._next_cursor_is_present(self.data):
self.req_args.get("params", {}).update(
{"cursor": self.data["response_metadata"]["next_cursor"]}
)
params = self.req_args.get("params", {})
if params is None:
params = {}
params.update({"cursor": self.data["response_metadata"]["next_cursor"]})
self.req_args.update({"params": params})

if self._use_sync_aiohttp:
# We no longer recommend going with this way
Expand Down
7 changes: 7 additions & 0 deletions tests/web/test_web_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,10 @@ async def test_issue_690_oauth_access_async(self):
self.assertIsNone(resp["error"])
with self.assertRaises(err.SlackApiError):
await self.async_client.oauth_access(client_id="999.999", client_secret="secret", code="codeeeeeeeeee")

def test_issue_705_no_param_request_pagination(self):
self.client.token = "xoxb-users_list_pagination"
users = []
for page in self.client.users_list():
users = users + page["members"]
self.assertTrue(len(users) == 4)

0 comments on commit 9a261bb

Please sign in to comment.