Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 30 additions & 25 deletions tests/adapter_tests_async/test_async_falcon.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,8 +2,9 @@
from time import time
from urllib.parse import quote

import pytest
import falcon
from falcon import testing
from falcon.testing import ASGIConductor

from slack_sdk.signature import SignatureVerifier
from slack_sdk.web.async_client import AsyncWebClient
Expand DownExpand Up@@ -55,7 +56,8 @@ def build_headers(self, timestamp: str, body: str):
"x-slack-request-timestamp": timestamp,
}

def test_events(self):
@pytest.mark.asyncio
async def test_events(self):
app = AsyncApp(
client=self.web_client,
signing_secret=self.signing_secret,
Expand DownExpand Up@@ -92,16 +94,17 @@ async def event_handler():
resource = AsyncSlackAppResource(app)
api.add_route("/slack/events", resource)

client = testing.TestClient(api)
response = client.simulate_post(
"/slack/events",
body=body,
headers=self.build_headers(timestamp, body),
)
async with ASGIConductor(api) as conductor:
response = await conductor.simulate_post(
"/slack/events",
body=body,
headers=self.build_headers(timestamp, body),
)
assert response.status_code == 200
assert_auth_test_count(self, 1)

def test_shortcuts(self):
@pytest.mark.asyncio
async def test_shortcuts(self):
app = AsyncApp(
client=self.web_client,
signing_secret=self.signing_secret,
Expand DownExpand Up@@ -133,16 +136,17 @@ async def shortcut_handler(ack):
resource = AsyncSlackAppResource(app)
api.add_route("/slack/events", resource)

client = testing.TestClient(api)
response = client.simulate_post(
"/slack/events",
body=body,
headers=self.build_headers(timestamp, body),
)
async with ASGIConductor(api) as conductor:
response = await conductor.simulate_post(
"/slack/events",
body=body,
headers=self.build_headers(timestamp, body),
)
assert response.status_code == 200
assert_auth_test_count(self, 1)

def test_commands(self):
@pytest.mark.asyncio
async def test_commands(self):
app = AsyncApp(
client=self.web_client,
signing_secret=self.signing_secret,
Expand DownExpand Up@@ -174,16 +178,17 @@ async def command_handler(ack):
resource = AsyncSlackAppResource(app)
api.add_route("/slack/events", resource)

client = testing.TestClient(api)
response = client.simulate_post(
"/slack/events",
body=body,
headers=self.build_headers(timestamp, body),
)
async with ASGIConductor(api) as conductor:
response = await conductor.simulate_post(
"/slack/events",
body=body,
headers=self.build_headers(timestamp, body),
)
assert response.status_code == 200
assert_auth_test_count(self, 1)

def test_oauth(self):
@pytest.mark.asyncio
async def test_oauth(self):
app = AsyncApp(
client=self.web_client,
signing_secret=self.signing_secret,
Expand All@@ -197,8 +202,8 @@ def test_oauth(self):
resource = AsyncSlackAppResource(app)
api.add_route("/slack/install", resource)

client = testing.TestClient(api)
response = client.simulate_get("/slack/install")
async with ASGIConductor(api) as conductor:
response = await conductor.simulate_get("/slack/install")
assert response.status_code == 200
assert response.headers.get("content-type") == "text/html; charset=utf-8"
assert response.headers.get("content-length") == "607"
Expand Down