|
| 1 | +import logging |
| 2 | +import os |
| 3 | +import unittest |
| 4 | + |
| 5 | +import pytest |
| 6 | + |
| 7 | +from integration_tests.env_variable_names import ( |
| 8 | + SLACK_SDK_TEST_GRID_ORG_ADMIN_USER_TOKEN, |
| 9 | +) |
| 10 | +from integration_tests.helpers import async_test, is_not_specified |
| 11 | +from slack_sdk.http_retry import RateLimitErrorRetryHandler |
| 12 | +from slack_sdk.http_retry.builtin_async_handlers import AsyncRateLimitErrorRetryHandler |
| 13 | +from slack_sdk.web import WebClient |
| 14 | +from slack_sdk.web.async_client import AsyncWebClient |
| 15 | + |
| 16 | + |
| 17 | +class TestWebClient(unittest.TestCase): |
| 18 | + """Runs integration tests with real Slack API""" |
| 19 | + |
| 20 | + def setUp(self): |
| 21 | + self.logger = logging.getLogger(__name__) |
| 22 | + self.org_admin_token = os.environ[SLACK_SDK_TEST_GRID_ORG_ADMIN_USER_TOKEN] |
| 23 | + self.sync_client: WebClient = WebClient(token=self.org_admin_token) |
| 24 | + self.sync_client.retry_handlers.append(RateLimitErrorRetryHandler(max_retry_count=2)) |
| 25 | + self.async_client: AsyncWebClient = AsyncWebClient(token=self.org_admin_token) |
| 26 | + self.async_client.retry_handlers.append( |
| 27 | + AsyncRateLimitErrorRetryHandler(max_retry_count=2) |
| 28 | + ) |
| 29 | + |
| 30 | + def tearDown(self): |
| 31 | + pass |
| 32 | + |
| 33 | + @pytest.mark.skipif(condition=is_not_specified(), reason="execution can take long") |
| 34 | + def test_sync(self): |
| 35 | + client = self.sync_client |
| 36 | + for response in client.admin_users_session_list(limit=1): |
| 37 | + self.assertIsNotNone(response.get("active_sessions")) |
| 38 | + |
| 39 | + @pytest.mark.skipif(condition=is_not_specified(), reason="execution can take long") |
| 40 | + @async_test |
| 41 | + async def test_async(self): |
| 42 | + client = self.async_client |
| 43 | + async for response in await client.admin_users_session_list(limit=1): |
| 44 | + self.assertIsNotNone(response.get("active_sessions")) |
0 commit comments