New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade test dependencies & fix Falcon warning #588
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
from datetime import datetime # type: ignore | ||
from http import HTTPStatus | ||
|
||
from falcon import Request, Response | ||
from falcon import Request, Response, version as falcon_version | ||
|
||
from slack_bolt import BoltResponse | ||
from slack_bolt.app import App | ||
|
@@ -50,7 +50,11 @@ def _to_bolt_request(self, req: Request) -> BoltRequest: | |
) | ||
|
||
def _write_response(self, bolt_resp: BoltResponse, resp: Response): | ||
resp.body = bolt_resp.body | ||
if falcon_version.__version__.startswith("2."): | ||
resp.body = bolt_resp.body | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
else: | ||
resp.text = bolt_resp.body | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
status = HTTPStatus(bolt_resp.status) | ||
resp.status = str(f"{status.value} {status.phrase}") | ||
resp.set_headers(bolt_resp.first_headers_without_set_cookie()) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
from urllib.parse import quote | ||
|
||
import falcon | ||
|
||
|
||
from falcon import testing | ||
from slack_sdk.signature import SignatureVerifier | ||
from slack_sdk.web import WebClient | ||
|
@@ -18,6 +20,13 @@ | |
from tests.utils import remove_os_env_temporarily, restore_os_env | ||
|
||
|
||
def new_falcon_app(): | ||
if falcon.version.__version__.startswith("2."): | ||
return falcon.API() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
else: | ||
return falcon.App() | ||
|
||
|
||
class TestFalcon: | ||
signing_secret = "secret" | ||
valid_token = "xoxb-valid" | ||
|
@@ -87,7 +96,7 @@ def event_handler(): | |
} | ||
timestamp, body = str(int(time())), json.dumps(input) | ||
|
||
api = falcon.API() | ||
api = new_falcon_app() | ||
resource = SlackAppResource(app) | ||
api.add_route("/slack/events", resource) | ||
|
||
|
@@ -128,7 +137,7 @@ def shortcut_handler(ack): | |
|
||
timestamp, body = str(int(time())), f"payload={quote(json.dumps(input))}" | ||
|
||
api = falcon.API() | ||
api = new_falcon_app() | ||
resource = SlackAppResource(app) | ||
api.add_route("/slack/events", resource) | ||
|
||
|
@@ -169,7 +178,7 @@ def command_handler(ack): | |
) | ||
timestamp, body = str(int(time())), input | ||
|
||
api = falcon.API() | ||
api = new_falcon_app() | ||
resource = SlackAppResource(app) | ||
api.add_route("/slack/events", resource) | ||
|
||
|
@@ -192,7 +201,7 @@ def test_oauth(self): | |
scopes=["chat:write", "commands"], | ||
), | ||
) | ||
api = falcon.API() | ||
api = new_falcon_app() | ||
resource = SlackAppResource(app) | ||
api.add_route("/slack/install", resource) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Organized the optional dependencies by moving test-related ones to this group