Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions integration_tests/web/test_issue_1305.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import asyncio
import os
import time
import unittest

from integration_tests.env_variable_names import SLACK_SDK_TEST_GRID_ORG_ADMIN_USER_TOKEN
from integration_tests.helpers import async_test
from slack_sdk.web import WebClient
from slack_sdk.web.async_client import AsyncWebClient


class TestWebClient(unittest.TestCase):
"""Runs integration tests with real Slack API

https://github.com/slackapi/python-slack-sdk/issues/1305
"""

def setUp(self):
self.org_admin_token = os.environ[SLACK_SDK_TEST_GRID_ORG_ADMIN_USER_TOKEN]
self.sync_client: WebClient = WebClient(token=self.org_admin_token)
self.async_client: AsyncWebClient = AsyncWebClient(token=self.org_admin_token)

def tearDown(self):
pass

def test_sync(self):
client = self.sync_client
count = 0

for page in client.admin_conversations_search(limit=1):
count += len(page["conversations"])
if count > 1:
break
time.sleep(1)

self.assertGreater(count, 0)

@async_test
async def test_async(self):
client = self.async_client
count = 0

async for page in await client.admin_conversations_search(limit=1):
count += len(page["conversations"])
if count > 1:
break
await asyncio.sleep(1)

self.assertGreater(count, 0)
3 changes: 2 additions & 1 deletion slack_sdk/web/async_slack_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ async def __anext__(self):
params = self.req_args.get("params", {})
if params is None:
params = {}
params.update({"cursor": self.data["response_metadata"]["next_cursor"]})
next_cursor = self.data.get("response_metadata", {}).get("next_cursor") or self.data.get("next_cursor")
params.update({"cursor": next_cursor})
self.req_args.update({"params": params})

response = await self._client._request( # skipcq: PYL-W0212
Expand Down