22from time import time
33from urllib .parse import quote
44
5+ import pytest
56import falcon
6- from falcon import testing
7+ from falcon . testing import ASGIConductor
78
89from slack_sdk .signature import SignatureVerifier
910from slack_sdk .web .async_client import AsyncWebClient
@@ -55,7 +56,8 @@ def build_headers(self, timestamp: str, body: str):
5556 "x-slack-request-timestamp" : timestamp ,
5657 }
5758
58- def test_events (self ):
59+ @pytest .mark .asyncio
60+ async def test_events (self ):
5961 app = AsyncApp (
6062 client = self .web_client ,
6163 signing_secret = self .signing_secret ,
@@ -92,16 +94,17 @@ async def event_handler():
9294 resource = AsyncSlackAppResource (app )
9395 api .add_route ("/slack/events" , resource )
9496
95- client = testing . TestClient (api )
96- response = client .simulate_post (
97- "/slack/events" ,
98- body = body ,
99- headers = self .build_headers (timestamp , body ),
100- )
97+ async with ASGIConductor (api ) as conductor :
98+ response = await conductor .simulate_post (
99+ "/slack/events" ,
100+ body = body ,
101+ headers = self .build_headers (timestamp , body ),
102+ )
101103 assert response .status_code == 200
102104 assert_auth_test_count (self , 1 )
103105
104- def test_shortcuts (self ):
106+ @pytest .mark .asyncio
107+ async def test_shortcuts (self ):
105108 app = AsyncApp (
106109 client = self .web_client ,
107110 signing_secret = self .signing_secret ,
@@ -133,16 +136,17 @@ async def shortcut_handler(ack):
133136 resource = AsyncSlackAppResource (app )
134137 api .add_route ("/slack/events" , resource )
135138
136- client = testing . TestClient (api )
137- response = client .simulate_post (
138- "/slack/events" ,
139- body = body ,
140- headers = self .build_headers (timestamp , body ),
141- )
139+ async with ASGIConductor (api ) as conductor :
140+ response = await conductor .simulate_post (
141+ "/slack/events" ,
142+ body = body ,
143+ headers = self .build_headers (timestamp , body ),
144+ )
142145 assert response .status_code == 200
143146 assert_auth_test_count (self , 1 )
144147
145- def test_commands (self ):
148+ @pytest .mark .asyncio
149+ async def test_commands (self ):
146150 app = AsyncApp (
147151 client = self .web_client ,
148152 signing_secret = self .signing_secret ,
@@ -174,16 +178,17 @@ async def command_handler(ack):
174178 resource = AsyncSlackAppResource (app )
175179 api .add_route ("/slack/events" , resource )
176180
177- client = testing . TestClient (api )
178- response = client .simulate_post (
179- "/slack/events" ,
180- body = body ,
181- headers = self .build_headers (timestamp , body ),
182- )
181+ async with ASGIConductor (api ) as conductor :
182+ response = await conductor .simulate_post (
183+ "/slack/events" ,
184+ body = body ,
185+ headers = self .build_headers (timestamp , body ),
186+ )
183187 assert response .status_code == 200
184188 assert_auth_test_count (self , 1 )
185189
186- def test_oauth (self ):
190+ @pytest .mark .asyncio
191+ async def test_oauth (self ):
187192 app = AsyncApp (
188193 client = self .web_client ,
189194 signing_secret = self .signing_secret ,
@@ -197,8 +202,8 @@ def test_oauth(self):
197202 resource = AsyncSlackAppResource (app )
198203 api .add_route ("/slack/install" , resource )
199204
200- client = testing . TestClient (api )
201- response = client .simulate_get ("/slack/install" )
205+ async with ASGIConductor (api ) as conductor :
206+ response = await conductor .simulate_get ("/slack/install" )
202207 assert response .status_code == 200
203208 assert response .headers .get ("content-type" ) == "text/html; charset=utf-8"
204209 assert response .headers .get ("content-length" ) == "607"
0 commit comments