File tree Expand file tree Collapse file tree 2 files changed +51
-1
lines changed
Expand file tree Collapse file tree 2 files changed +51
-1
lines changed Original file line number Diff line number Diff line change 1+ import asyncio
2+ import os
3+ import time
4+ import unittest
5+
6+ from integration_tests .env_variable_names import SLACK_SDK_TEST_GRID_ORG_ADMIN_USER_TOKEN
7+ from integration_tests .helpers import async_test
8+ from slack_sdk .web import WebClient
9+ from slack_sdk .web .async_client import AsyncWebClient
10+
11+
12+ class TestWebClient (unittest .TestCase ):
13+ """Runs integration tests with real Slack API
14+
15+ https://github.com/slackapi/python-slack-sdk/issues/1305
16+ """
17+
18+ def setUp (self ):
19+ self .org_admin_token = os .environ [SLACK_SDK_TEST_GRID_ORG_ADMIN_USER_TOKEN ]
20+ self .sync_client : WebClient = WebClient (token = self .org_admin_token )
21+ self .async_client : AsyncWebClient = AsyncWebClient (token = self .org_admin_token )
22+
23+ def tearDown (self ):
24+ pass
25+
26+ def test_sync (self ):
27+ client = self .sync_client
28+ count = 0
29+
30+ for page in client .admin_conversations_search (limit = 1 ):
31+ count += len (page ["conversations" ])
32+ if count > 1 :
33+ break
34+ time .sleep (1 )
35+
36+ self .assertGreater (count , 0 )
37+
38+ @async_test
39+ async def test_async (self ):
40+ client = self .async_client
41+ count = 0
42+
43+ async for page in await client .admin_conversations_search (limit = 1 ):
44+ count += len (page ["conversations" ])
45+ if count > 1 :
46+ break
47+ await asyncio .sleep (1 )
48+
49+ self .assertGreater (count , 0 )
Original file line number Diff line number Diff line change @@ -145,7 +145,8 @@ async def __anext__(self):
145145 params = self .req_args .get ("params" , {})
146146 if params is None :
147147 params = {}
148- params .update ({"cursor" : self .data ["response_metadata" ]["next_cursor" ]})
148+ next_cursor = self .data .get ("response_metadata" , {}).get ("next_cursor" ) or self .data .get ("next_cursor" )
149+ params .update ({"cursor" : next_cursor })
149150 self .req_args .update ({"params" : params })
150151
151152 response = await self ._client ._request ( # skipcq: PYL-W0212
You can’t perform that action at this time.
0 commit comments