Skip to content

Commit 91f9ef1

Browse files
feat: improve test speed (#1017)
* 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]>
1 parent 69e033f commit 91f9ef1

28 files changed

+307
-380
lines changed

tests/adapter_tests/aws/test_aws_chalice.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from slack_bolt.app import App
2222
from slack_bolt.oauth.oauth_settings import OAuthSettings
2323
from tests.mock_web_api_server import (
24+
assert_received_request_count,
2425
setup_mock_web_api_server,
2526
cleanup_mock_web_api_server,
2627
assert_auth_test_count,
@@ -263,7 +264,7 @@ def say_it(say):
263264
response: Response = slack_handler.handle(request)
264265
assert response.status_code == 200
265266
assert_auth_test_count(self, 1)
266-
assert self.mock_received_requests["/chat.postMessage"] == 1
267+
assert_received_request_count(self, "/chat.postMessage", 1)
267268

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

317318
assert response.status_code == 200, f"Failed request: {response.body}"
318319
assert_auth_test_count(self, 1)
319-
assert self.mock_received_requests["/chat.postMessage"] == 1
320+
assert_received_request_count(self, "/chat.postMessage", 1)
320321

321322
@mock.patch(
322323
"slack_bolt.adapter.aws_lambda.chalice_lazy_listener_runner.boto3",

tests/adapter_tests/aws/test_aws_lambda.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from slack_bolt.app import App
1414
from slack_bolt.oauth.oauth_settings import OAuthSettings
1515
from tests.mock_web_api_server import (
16+
assert_received_request_count,
1617
setup_mock_web_api_server,
1718
cleanup_mock_web_api_server,
1819
assert_auth_test_count,
@@ -279,7 +280,7 @@ def say_it(say):
279280
response = SlackRequestHandler(app).handle(event, self.context)
280281
assert response["statusCode"] == 200
281282
assert_auth_test_count(self, 1)
282-
assert self.mock_received_requests["/chat.postMessage"] == 1
283+
assert_received_request_count(self, "/chat.postMessage", 1)
283284

284285
@mock_lambda
285286
def test_oauth(self):

tests/adapter_tests_async/test_async_asgi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,4 +221,4 @@ async def test_url_verification(self):
221221

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

0 commit comments

Comments
 (0)