Skip to content

Commit

Permalink
feat: improve test speed (#1017)
Browse files Browse the repository at this point in the history
* Speed up the tests

* make all tests pass

* Update tests/mock_web_api_server.py

Co-authored-by: Kazuhiro Sera <[email protected]>

* health endpoint not required

* Update tests/mock_web_api_server.py

Co-authored-by: Kazuhiro Sera <[email protected]>

* Move responses out of class

* Improve naming

* More time saving

---------

Co-authored-by: Kazuhiro Sera <[email protected]>
  • Loading branch information
WilliamBergamin and seratch authored Feb 7, 2024
1 parent 69e033f commit 91f9ef1
Show file tree
Hide file tree
Showing 28 changed files with 307 additions and 380 deletions.
5 changes: 3 additions & 2 deletions tests/adapter_tests/aws/test_aws_chalice.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from slack_bolt.app import App
from slack_bolt.oauth.oauth_settings import OAuthSettings
from tests.mock_web_api_server import (
assert_received_request_count,
setup_mock_web_api_server,
cleanup_mock_web_api_server,
assert_auth_test_count,
Expand Down Expand Up @@ -263,7 +264,7 @@ def say_it(say):
response: Response = slack_handler.handle(request)
assert response.status_code == 200
assert_auth_test_count(self, 1)
assert self.mock_received_requests["/chat.postMessage"] == 1
assert_received_request_count(self, "/chat.postMessage", 1)

def test_lazy_listeners_cli(self):
with mock.patch.dict(os.environ, {"AWS_CHALICE_CLI_MODE": "true"}):
Expand Down Expand Up @@ -316,7 +317,7 @@ def events() -> Response:

assert response.status_code == 200, f"Failed request: {response.body}"
assert_auth_test_count(self, 1)
assert self.mock_received_requests["/chat.postMessage"] == 1
assert_received_request_count(self, "/chat.postMessage", 1)

@mock.patch(
"slack_bolt.adapter.aws_lambda.chalice_lazy_listener_runner.boto3",
Expand Down
3 changes: 2 additions & 1 deletion tests/adapter_tests/aws/test_aws_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from slack_bolt.app import App
from slack_bolt.oauth.oauth_settings import OAuthSettings
from tests.mock_web_api_server import (
assert_received_request_count,
setup_mock_web_api_server,
cleanup_mock_web_api_server,
assert_auth_test_count,
Expand Down Expand Up @@ -279,7 +280,7 @@ def say_it(say):
response = SlackRequestHandler(app).handle(event, self.context)
assert response["statusCode"] == 200
assert_auth_test_count(self, 1)
assert self.mock_received_requests["/chat.postMessage"] == 1
assert_received_request_count(self, "/chat.postMessage", 1)

@mock_lambda
def test_oauth(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/adapter_tests_async/test_async_asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,4 @@ async def test_url_verification(self):

assert response.status_code == 200
assert response.headers.get("content-type") == "application/json;charset=utf-8"
assert_auth_test_count(self, 1)
assert_auth_test_count(self, 0)
Loading

0 comments on commit 91f9ef1

Please sign in to comment.