-
Notifications
You must be signed in to change notification settings - Fork 835
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fix #1305 by fixing pagination with async for syntax * Remove unnecessary imports
- Loading branch information
Showing
2 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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,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) |
This file contains 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