11import os
2+ from tests .helpers import async_test
23import unittest
34import time
45
1516from slack_sdk .models .blocks .basic_components import MarkdownTextObject , PlainTextObject
1617
1718
18- class TestAsyncWebhook (unittest .IsolatedAsyncioTestCase ):
19- async def asyncSetUp (self ):
19+ class TestAsyncWebhook (unittest .TestCase ):
20+ @async_test
21+ async def setUp (self ):
2022 if not hasattr (self , "channel_id" ):
2123 token = os .environ [SLACK_SDK_TEST_BOT_TOKEN ]
2224 channel_name = os .environ [
@@ -35,6 +37,7 @@ async def asyncSetUp(self):
3537 def tearDown (self ):
3638 pass
3739
40+ @async_test
3841 async def test_webhook (self ):
3942 url = os .environ [SLACK_SDK_TEST_INCOMING_WEBHOOK_URL ]
4043 webhook = AsyncWebhookClient (url )
@@ -49,6 +52,7 @@ async def test_webhook(self):
4952 actual_text = history ["messages" ][0 ]["text" ]
5053 self .assertEqual ("Hello!" , actual_text )
5154
55+ @async_test
5256 async def test_with_unfurls_off (self ):
5357 url = os .environ [SLACK_SDK_TEST_INCOMING_WEBHOOK_URL ]
5458 token = os .environ [SLACK_SDK_TEST_BOT_TOKEN ]
@@ -68,6 +72,7 @@ async def test_with_unfurls_off(self):
6872 self .assertIsNotNone (history )
6973 self .assertTrue ("attachments" not in history ["messages" ][0 ])
7074
75+ @async_test
7176 async def test_with_unfurls_on (self ):
7277 # Slack API rate limits unfurls of unique links so test will
7378 # fail when repeated. For testing, either use a different URL
@@ -90,6 +95,7 @@ async def test_with_unfurls_on(self):
9095 self .assertIsNotNone (history )
9196 self .assertTrue ("attachments" in history ["messages" ][0 ])
9297
98+ @async_test
9399 async def test_with_blocks (self ):
94100 url = os .environ [SLACK_SDK_TEST_INCOMING_WEBHOOK_URL ]
95101 webhook = AsyncWebhookClient (url )
@@ -130,6 +136,7 @@ async def test_with_blocks(self):
130136 self .assertEqual (200 , response .status_code )
131137 self .assertEqual ("ok" , response .body )
132138
139+ @async_test
133140 async def test_with_blocks_dict (self ):
134141 url = os .environ [SLACK_SDK_TEST_INCOMING_WEBHOOK_URL ]
135142 webhook = AsyncWebhookClient (url )
@@ -198,6 +205,7 @@ async def test_with_blocks_dict(self):
198205 self .assertEqual (200 , response .status_code )
199206 self .assertEqual ("ok" , response .body )
200207
208+ @async_test
201209 async def test_with_attachments (self ):
202210 url = os .environ [SLACK_SDK_TEST_INCOMING_WEBHOOK_URL ]
203211 webhook = AsyncWebhookClient (url )
@@ -231,6 +239,7 @@ async def test_with_attachments(self):
231239 self .assertEqual (200 , response .status_code )
232240 self .assertEqual ("ok" , response .body )
233241
242+ @async_test
234243 async def test_with_attachments_dict (self ):
235244 url = os .environ [SLACK_SDK_TEST_INCOMING_WEBHOOK_URL ]
236245 webhook = AsyncWebhookClient (url )
0 commit comments