diff --git a/examples/app_authorize.py b/examples/app_authorize.py index 0b81e9b66..3f4ab5b01 100644 --- a/examples/app_authorize.py +++ b/examples/app_authorize.py @@ -7,6 +7,7 @@ # ------------------------------------------------ import logging + logging.basicConfig(level=logging.DEBUG) import os @@ -14,6 +15,7 @@ from slack_bolt.authorization import AuthorizeResult from slack_sdk import WebClient + def authorize(enterprise_id, team_id, user_id, client: WebClient, logger): logger.info(f"{enterprise_id},{team_id},{user_id}") # You can implement your own logic here @@ -23,10 +25,9 @@ def authorize(enterprise_id, team_id, user_id, client: WebClient, logger): bot_token=token, ) -app = App( - signing_secret=os.environ["SLACK_SIGNING_SECRET"], - authorize=authorize -) + +app = App(signing_secret=os.environ["SLACK_SIGNING_SECRET"], authorize=authorize) + @app.command("/hello-bolt-python") def hello_command(ack, body): diff --git a/examples/async_app_authorize.py b/examples/async_app_authorize.py index aee349331..cb62fe925 100644 --- a/examples/async_app_authorize.py +++ b/examples/async_app_authorize.py @@ -14,6 +14,7 @@ from slack_bolt.authorization import AuthorizeResult from slack_bolt.async_app import AsyncApp + async def authorize(enterprise_id, team_id, user_id, client: AsyncWebClient, logger): logger.info(f"{enterprise_id},{team_id},{user_id}") # You can implement your own logic here @@ -24,10 +25,8 @@ async def authorize(enterprise_id, team_id, user_id, client: AsyncWebClient, log ) -app = AsyncApp( - signing_secret=os.environ["SLACK_SIGNING_SECRET"], - authorize=authorize -) +app = AsyncApp(signing_secret=os.environ["SLACK_SIGNING_SECRET"], authorize=authorize) + @app.event("app_mention") async def event_test(body, say, logger): diff --git a/examples/async_steps_from_apps.py b/examples/async_steps_from_apps.py index e38e352bb..061012eb0 100644 --- a/examples/async_steps_from_apps.py +++ b/examples/async_steps_from_apps.py @@ -9,7 +9,12 @@ from slack_sdk.web.async_client import AsyncSlackResponse, AsyncWebClient from slack_bolt.async_app import AsyncApp, AsyncAck -from slack_bolt.workflows.step.async_step import AsyncConfigure, AsyncUpdate, AsyncComplete, AsyncFail +from slack_bolt.workflows.step.async_step import ( + AsyncConfigure, + AsyncUpdate, + AsyncComplete, + AsyncFail, +) logging.basicConfig(level=logging.DEBUG) @@ -93,7 +98,11 @@ async def save(ack: AsyncAck, view: dict, update: AsyncUpdate): }, }, outputs=[ - {"name": "taskName", "type": "text", "label": "Task Name", }, + { + "name": "taskName", + "type": "text", + "label": "Task Name", + }, { "name": "taskDescription", "type": "text", @@ -104,7 +113,7 @@ async def save(ack: AsyncAck, view: dict, update: AsyncUpdate): "type": "text", "label": "Task Author Email", }, - ] + ], ) await ack() @@ -112,7 +121,9 @@ async def save(ack: AsyncAck, view: dict, update: AsyncUpdate): pseudo_database = {} -async def execute(step: dict, client: AsyncWebClient, complete: AsyncComplete, fail: AsyncFail): +async def execute( + step: dict, client: AsyncWebClient, complete: AsyncComplete, fail: AsyncFail +): try: await complete( outputs={ @@ -152,9 +163,7 @@ async def execute(step: dict, client: AsyncWebClient, complete: AsyncComplete, f }, ) except: - await fail(error={ - "message": "Something wrong!" - }) + await fail(error={"message": "Something wrong!"}) app.step( diff --git a/examples/async_steps_from_apps_primitive.py b/examples/async_steps_from_apps_primitive.py index 3c65addf0..905fc38a8 100644 --- a/examples/async_steps_from_apps_primitive.py +++ b/examples/async_steps_from_apps_primitive.py @@ -102,7 +102,11 @@ async def save(ack: AsyncAck, client: AsyncWebClient, body: dict): }, }, "outputs": [ - {"name": "taskName", "type": "text", "label": "Task Name",}, + { + "name": "taskName", + "type": "text", + "label": "Task Name", + }, { "name": "taskDescription", "type": "text", diff --git a/examples/aws_chalice/app.py b/examples/aws_chalice/app.py index 59facf400..248f58a01 100644 --- a/examples/aws_chalice/app.py +++ b/examples/aws_chalice/app.py @@ -19,13 +19,14 @@ def handle_app_mentions(body, say, logger): def respond_to_slack_within_3_seconds(ack): ack("Accepted!") + def say_it(say): time.sleep(5) say("Done!") + bolt_app.command("/hello-bolt-python-chalice")( - ack=respond_to_slack_within_3_seconds, - lazy=[say_it] + ack=respond_to_slack_within_3_seconds, lazy=[say_it] ) ChaliceSlackRequestHandler.clear_all_log_handlers() diff --git a/examples/aws_lambda/aws_lambda_oauth.py b/examples/aws_lambda/aws_lambda_oauth.py index f7210dc85..348da4b2e 100644 --- a/examples/aws_lambda/aws_lambda_oauth.py +++ b/examples/aws_lambda/aws_lambda_oauth.py @@ -12,7 +12,10 @@ from slack_bolt.adapter.aws_lambda.lambda_s3_oauth_flow import LambdaS3OAuthFlow # process_before_response must be True when running on FaaS -app = App(process_before_response=True, oauth_flow=LambdaS3OAuthFlow(),) +app = App( + process_before_response=True, + oauth_flow=LambdaS3OAuthFlow(), +) @app.event("app_mention") diff --git a/examples/dialogs_app.py b/examples/dialogs_app.py index 46265afbc..e2f23e3ed 100644 --- a/examples/dialogs_app.py +++ b/examples/dialogs_app.py @@ -64,7 +64,7 @@ def dialog_submission_or_cancellation(ack: Ack, body: dict): errors = [ { "name": "loc_origin", - "error": "Pickup Location must be longer than 3 characters" + "error": "Pickup Location must be longer than 3 characters", } ] if len(errors) > 0: @@ -116,7 +116,6 @@ def dialog_suggestion(ack): ) - if __name__ == "__main__": app.start(3000) diff --git a/examples/django/slackapp/migrations/0001_initial.py b/examples/django/slackapp/migrations/0001_initial.py index 5d256685d..a2bcb49ef 100644 --- a/examples/django/slackapp/migrations/0001_initial.py +++ b/examples/django/slackapp/migrations/0001_initial.py @@ -7,69 +7,104 @@ class Migration(migrations.Migration): initial = True - dependencies = [ - ] + dependencies = [] operations = [ migrations.CreateModel( - name='SlackBot', + name="SlackBot", fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('client_id', models.TextField()), - ('app_id', models.TextField()), - ('enterprise_id', models.TextField(null=True)), - ('enterprise_name', models.TextField(null=True)), - ('team_id', models.TextField(null=True)), - ('team_name', models.TextField(null=True)), - ('bot_token', models.TextField(null=True)), - ('bot_id', models.TextField(null=True)), - ('bot_user_id', models.TextField(null=True)), - ('bot_scopes', models.TextField(null=True)), - ('is_enterprise_install', models.BooleanField(null=True)), - ('installed_at', models.DateTimeField()), + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("client_id", models.TextField()), + ("app_id", models.TextField()), + ("enterprise_id", models.TextField(null=True)), + ("enterprise_name", models.TextField(null=True)), + ("team_id", models.TextField(null=True)), + ("team_name", models.TextField(null=True)), + ("bot_token", models.TextField(null=True)), + ("bot_id", models.TextField(null=True)), + ("bot_user_id", models.TextField(null=True)), + ("bot_scopes", models.TextField(null=True)), + ("is_enterprise_install", models.BooleanField(null=True)), + ("installed_at", models.DateTimeField()), ], ), migrations.CreateModel( - name='SlackInstallation', + name="SlackInstallation", fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('client_id', models.TextField()), - ('app_id', models.TextField()), - ('enterprise_id', models.TextField(null=True)), - ('enterprise_name', models.TextField(null=True)), - ('enterprise_url', models.TextField(null=True)), - ('team_id', models.TextField(null=True)), - ('team_name', models.TextField(null=True)), - ('bot_token', models.TextField(null=True)), - ('bot_id', models.TextField(null=True)), - ('bot_user_id', models.TextField(null=True)), - ('bot_scopes', models.TextField(null=True)), - ('user_id', models.TextField()), - ('user_token', models.TextField(null=True)), - ('user_scopes', models.TextField(null=True)), - ('incoming_webhook_url', models.TextField(null=True)), - ('incoming_webhook_channel', models.TextField(null=True)), - ('incoming_webhook_channel_id', models.TextField(null=True)), - ('incoming_webhook_configuration_url', models.TextField(null=True)), - ('is_enterprise_install', models.BooleanField(null=True)), - ('token_type', models.TextField(null=True)), - ('installed_at', models.DateTimeField()), + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("client_id", models.TextField()), + ("app_id", models.TextField()), + ("enterprise_id", models.TextField(null=True)), + ("enterprise_name", models.TextField(null=True)), + ("enterprise_url", models.TextField(null=True)), + ("team_id", models.TextField(null=True)), + ("team_name", models.TextField(null=True)), + ("bot_token", models.TextField(null=True)), + ("bot_id", models.TextField(null=True)), + ("bot_user_id", models.TextField(null=True)), + ("bot_scopes", models.TextField(null=True)), + ("user_id", models.TextField()), + ("user_token", models.TextField(null=True)), + ("user_scopes", models.TextField(null=True)), + ("incoming_webhook_url", models.TextField(null=True)), + ("incoming_webhook_channel", models.TextField(null=True)), + ("incoming_webhook_channel_id", models.TextField(null=True)), + ("incoming_webhook_configuration_url", models.TextField(null=True)), + ("is_enterprise_install", models.BooleanField(null=True)), + ("token_type", models.TextField(null=True)), + ("installed_at", models.DateTimeField()), ], ), migrations.CreateModel( - name='SlackOAuthState', + name="SlackOAuthState", fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('state', models.TextField()), - ('expire_at', models.DateTimeField()), + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("state", models.TextField()), + ("expire_at", models.DateTimeField()), ], ), migrations.AddIndex( - model_name='slackinstallation', - index=models.Index(fields=['client_id', 'enterprise_id', 'team_id', 'user_id', 'installed_at'], name='bolt_slacki_client__62c411_idx'), + model_name="slackinstallation", + index=models.Index( + fields=[ + "client_id", + "enterprise_id", + "team_id", + "user_id", + "installed_at", + ], + name="bolt_slacki_client__62c411_idx", + ), ), migrations.AddIndex( - model_name='slackbot', - index=models.Index(fields=['client_id', 'enterprise_id', 'team_id', 'installed_at'], name='bolt_slackb_client__be066b_idx'), + model_name="slackbot", + index=models.Index( + fields=["client_id", "enterprise_id", "team_id", "installed_at"], + name="bolt_slackb_client__be066b_idx", + ), ), ] diff --git a/examples/django/slackapp/models.py b/examples/django/slackapp/models.py index 6069ce345..737c4bd90 100644 --- a/examples/django/slackapp/models.py +++ b/examples/django/slackapp/models.py @@ -4,6 +4,7 @@ from django.db import models + class SlackBot(models.Model): client_id = models.TextField(null=False) app_id = models.TextField(null=False) @@ -86,7 +87,9 @@ class DjangoInstallationStore(InstallationStore): client_id: str def __init__( - self, client_id: str, logger: Logger, + self, + client_id: str, + logger: Logger, ): self.client_id = client_id self._logger = logger @@ -104,8 +107,11 @@ def save(self, installation: Installation): SlackBot(**b).save() def find_bot( - self, *, enterprise_id: Optional[str], team_id: Optional[str], - is_enterprise_install: Optional[bool] = False + self, + *, + enterprise_id: Optional[str], + team_id: Optional[str], + is_enterprise_install: Optional[bool] = False, ) -> Optional[Bot]: e_id = enterprise_id or None t_id = team_id or None @@ -143,13 +149,18 @@ def find_installation( if is_enterprise_install: t_id = None if user_id is None: - rows = (SlackInstallation.objects.filter( - enterprise_id=e_id).filter(team_id=t_id).order_by( - F("installed_at").desc())[:1]) + rows = ( + SlackInstallation.objects.filter(enterprise_id=e_id) + .filter(team_id=t_id) + .order_by(F("installed_at").desc())[:1] + ) else: - rows = (SlackInstallation.objects.filter( - enterprise_id=e_id).filter(team_id=t_id).filter( - user_id=user_id).order_by(F("installed_at").desc())[:1]) + rows = ( + SlackInstallation.objects.filter(enterprise_id=e_id) + .filter(team_id=t_id) + .filter(user_id=user_id) + .order_by(F("installed_at").desc())[:1] + ) if len(rows) > 0: i = rows[0] @@ -176,7 +187,9 @@ class DjangoOAuthStateStore(OAuthStateStore): expiration_seconds: int def __init__( - self, expiration_seconds: int, logger: Logger, + self, + expiration_seconds: int, + logger: Logger, ): self.expiration_seconds = expiration_seconds self._logger = logger @@ -202,6 +215,7 @@ def consume(self, state: str) -> bool: return True return False + # ---------------------- # Slack App # ---------------------- @@ -220,11 +234,17 @@ def consume(self, state: str) -> bool: app = App( signing_secret=signing_secret, - installation_store=DjangoInstallationStore(client_id=client_id, logger=logger,), + installation_store=DjangoInstallationStore( + client_id=client_id, + logger=logger, + ), oauth_settings=OAuthSettings( client_id=client_id, client_secret=client_secret, - state_store=DjangoOAuthStateStore(expiration_seconds=120, logger=logger,), + state_store=DjangoOAuthStateStore( + expiration_seconds=120, + logger=logger, + ), ), ) @@ -234,6 +254,7 @@ def event_test(body, say, logger): logger.info(body) say("What's up?") + @app.command("/hello-bolt-python") def command(ack): - ack("This is a Django app!") \ No newline at end of file + ack("This is a Django app!") diff --git a/examples/django/slackapp/settings.py b/examples/django/slackapp/settings.py index 13252519b..1553e7df3 100644 --- a/examples/django/slackapp/settings.py +++ b/examples/django/slackapp/settings.py @@ -15,16 +15,29 @@ LOGGING = { "version": 1, "disable_existing_loggers": False, - "handlers": {"console": {"class": "logging.StreamHandler",},}, - "root": {"handlers": ["console"], "level": "INFO",}, + "handlers": { + "console": { + "class": "logging.StreamHandler", + }, + }, + "root": { + "handlers": ["console"], + "level": "INFO", + }, "loggers": { "django": { "handlers": ["console"], "level": os.getenv("DJANGO_LOG_LEVEL", "INFO"), "propagate": False, }, - "django.db.backends": {"level": "DEBUG",}, - "slack_bolt": {"handlers": ["console"], "level": "DEBUG", "propagate": False,}, + "django.db.backends": { + "level": "DEBUG", + }, + "slack_bolt": { + "handlers": ["console"], + "level": "DEBUG", + "propagate": False, + }, }, } @@ -105,9 +118,15 @@ { "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", }, - {"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",}, - {"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",}, - {"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",}, + { + "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", + }, ] # Internationalization diff --git a/examples/falcon/app.py b/examples/falcon/app.py index 40e32e93d..1dbf39ffb 100644 --- a/examples/falcon/app.py +++ b/examples/falcon/app.py @@ -52,14 +52,26 @@ def test_shortcut(ack, client: WebClient, logger, body): view={ "type": "modal", "callback_id": "view-id", - "title": {"type": "plain_text", "text": "My App",}, - "submit": {"type": "plain_text", "text": "Submit",}, - "close": {"type": "plain_text", "text": "Cancel",}, + "title": { + "type": "plain_text", + "text": "My App", + }, + "submit": { + "type": "plain_text", + "text": "Submit", + }, + "close": { + "type": "plain_text", + "text": "Cancel", + }, "blocks": [ { "type": "input", "element": {"type": "plain_text_input"}, - "label": {"type": "plain_text", "text": "Label",}, + "label": { + "type": "plain_text", + "text": "Label", + }, } ], }, diff --git a/examples/falcon/oauth_app.py b/examples/falcon/oauth_app.py index 167003a9c..900ffca99 100644 --- a/examples/falcon/oauth_app.py +++ b/examples/falcon/oauth_app.py @@ -52,14 +52,26 @@ def test_shortcut(ack, client: WebClient, logger, body): view={ "type": "modal", "callback_id": "view-id", - "title": {"type": "plain_text", "text": "My App",}, - "submit": {"type": "plain_text", "text": "Submit",}, - "close": {"type": "plain_text", "text": "Cancel",}, + "title": { + "type": "plain_text", + "text": "My App", + }, + "submit": { + "type": "plain_text", + "text": "Submit", + }, + "close": { + "type": "plain_text", + "text": "Cancel", + }, "blocks": [ { "type": "input", "element": {"type": "plain_text_input"}, - "label": {"type": "plain_text", "text": "Label",}, + "label": { + "type": "plain_text", + "text": "Label", + }, } ], }, diff --git a/examples/fastapi/async_oauth_app.py b/examples/fastapi/async_oauth_app.py index 8ba33668a..a19ba402c 100644 --- a/examples/fastapi/async_oauth_app.py +++ b/examples/fastapi/async_oauth_app.py @@ -6,6 +6,7 @@ # ------------------------------------------------ import logging + logging.basicConfig(level=logging.DEBUG) from slack_bolt.async_app import AsyncApp diff --git a/examples/getting_started/app.py b/examples/getting_started/app.py index 23fd2f96d..e394dd2fa 100644 --- a/examples/getting_started/app.py +++ b/examples/getting_started/app.py @@ -4,7 +4,7 @@ # Initializes your app with your bot token and signing secret app = App( token=os.environ.get("SLACK_BOT_TOKEN"), - signing_secret=os.environ.get("SLACK_SIGNING_SECRET") + signing_secret=os.environ.get("SLACK_SIGNING_SECRET"), ) # Listens to incoming messages that contain "hello" @@ -15,29 +15,25 @@ def message_hello(message, say): blocks=[ { "type": "section", - "text": { - "type": "mrkdwn", - "text": f"Hey there <@{message['user']}>!" - }, + "text": {"type": "mrkdwn", "text": f"Hey there <@{message['user']}>!"}, "accessory": { "type": "button", - "text": { - "type": "plain_text", - "text": "Click Me" - }, - "action_id": "button_click" - } + "text": {"type": "plain_text", "text": "Click Me"}, + "action_id": "button_click", + }, } ], - text=f"Hey there <@{message['user']}>!" + text=f"Hey there <@{message['user']}>!", ) + @app.action("button_click") def action_button_click(body, ack, say): # Acknowledge the action ack() say(f"<@{body['user']['id']}> clicked the button") + # Start your app if __name__ == "__main__": - app.start(port=int(os.environ.get("PORT", 3000))) \ No newline at end of file + app.start(port=int(os.environ.get("PORT", 3000))) diff --git a/examples/lazy_async_modals_app.py b/examples/lazy_async_modals_app.py index a566cdf56..7f25d5a73 100644 --- a/examples/lazy_async_modals_app.py +++ b/examples/lazy_async_modals_app.py @@ -52,14 +52,26 @@ async def open_modal(body, client, logger): view={ "type": "modal", "callback_id": "view-id", - "title": {"type": "plain_text", "text": "My App",}, - "submit": {"type": "plain_text", "text": "Submit",}, - "close": {"type": "plain_text", "text": "Cancel",}, + "title": { + "type": "plain_text", + "text": "My App", + }, + "submit": { + "type": "plain_text", + "text": "Submit", + }, + "close": { + "type": "plain_text", + "text": "Cancel", + }, "blocks": [ { "type": "input", "element": {"type": "plain_text_input"}, - "label": {"type": "plain_text", "text": "Label",}, + "label": { + "type": "plain_text", + "text": "Label", + }, }, { "type": "input", @@ -90,7 +102,8 @@ async def open_modal(body, client, logger): app.command("/hello-bolt-python")( - ack=ack_command, lazy=[post_button_message, open_modal], + ack=ack_command, + lazy=[post_button_message, open_modal], ) diff --git a/examples/lazy_modals_app.py b/examples/lazy_modals_app.py index 4de8c7778..9b668a859 100644 --- a/examples/lazy_modals_app.py +++ b/examples/lazy_modals_app.py @@ -53,14 +53,26 @@ def open_modal(body, client, logger): view={ "type": "modal", "callback_id": "view-id", - "title": {"type": "plain_text", "text": "My App",}, - "submit": {"type": "plain_text", "text": "Submit",}, - "close": {"type": "plain_text", "text": "Cancel",}, + "title": { + "type": "plain_text", + "text": "My App", + }, + "submit": { + "type": "plain_text", + "text": "Submit", + }, + "close": { + "type": "plain_text", + "text": "Cancel", + }, "blocks": [ { "type": "input", "element": {"type": "plain_text_input"}, - "label": {"type": "plain_text", "text": "Label",}, + "label": { + "type": "plain_text", + "text": "Label", + }, }, { "type": "input", @@ -91,7 +103,8 @@ def open_modal(body, client, logger): app.command("/hello-bolt-python")( - ack=ack_command, lazy=[post_button_message, open_modal], + ack=ack_command, + lazy=[post_button_message, open_modal], ) diff --git a/examples/message_events.py b/examples/message_events.py index e732fd3f6..e0693f7b6 100644 --- a/examples/message_events.py +++ b/examples/message_events.py @@ -75,7 +75,9 @@ def add_reaction( logger.info(f"subtype: {subtype}") message_ts = body["event"]["ts"] api_response = client.reactions_add( - channel=context.channel_id, timestamp=message_ts, name="eyes", + channel=context.channel_id, + timestamp=message_ts, + name="eyes", ) logger.info(f"api_response: {api_response}") diff --git a/examples/modals_app.py b/examples/modals_app.py index 7859028ff..f0da8d9f8 100644 --- a/examples/modals_app.py +++ b/examples/modals_app.py @@ -29,7 +29,10 @@ def handle_command(body, ack, respond, client, logger): { "type": "section", "block_id": "b", - "text": {"type": "mrkdwn", "text": ":white_check_mark: Accepted!",}, + "text": { + "type": "mrkdwn", + "text": ":white_check_mark: Accepted!", + }, } ], ) @@ -58,14 +61,26 @@ def handle_command(body, ack, respond, client, logger): view={ "type": "modal", "callback_id": "view-id", - "title": {"type": "plain_text", "text": "My App",}, - "submit": {"type": "plain_text", "text": "Submit",}, - "close": {"type": "plain_text", "text": "Cancel",}, + "title": { + "type": "plain_text", + "text": "My App", + }, + "submit": { + "type": "plain_text", + "text": "Submit", + }, + "close": { + "type": "plain_text", + "text": "Cancel", + }, "blocks": [ { "type": "input", "element": {"type": "plain_text_input"}, - "label": {"type": "plain_text", "text": "Label",}, + "label": { + "type": "plain_text", + "text": "Label", + }, }, { "type": "input", @@ -155,7 +170,8 @@ def button_click(ack, body, respond): ) # ephemeral / kwargs respond( - replace_original=False, text=":white_check_mark: Done!", + replace_original=False, + text=":white_check_mark: Done!", ) diff --git a/examples/modals_app_typed.py b/examples/modals_app_typed.py index 62821bb23..ffad223cf 100644 --- a/examples/modals_app_typed.py +++ b/examples/modals_app_typed.py @@ -123,7 +123,9 @@ def show_multi_options(ack: Ack) -> None: ), OptionGroup( label=PlainTextObject(text="Group 2"), - options=[Option(text=PlainTextObject(text="Option 1"), value="2-1"),], + options=[ + Option(text=PlainTextObject(text="Option 1"), value="2-1"), + ], ), ] ) @@ -148,7 +150,8 @@ def button_click(ack: Ack, body: dict, respond: Respond) -> None: ) # ephemeral / kwargs respond( - replace_original=False, text=":white_check_mark: Done!", + replace_original=False, + text=":white_check_mark: Done!", ) diff --git a/examples/oauth_app.py b/examples/oauth_app.py index 596b52fad..26b772a77 100644 --- a/examples/oauth_app.py +++ b/examples/oauth_app.py @@ -48,14 +48,26 @@ def test_command(body, respond, client, ack, logger): view={ "type": "modal", "callback_id": "view-id", - "title": {"type": "plain_text", "text": "My App",}, - "submit": {"type": "plain_text", "text": "Submit",}, - "close": {"type": "plain_text", "text": "Cancel",}, + "title": { + "type": "plain_text", + "text": "My App", + }, + "submit": { + "type": "plain_text", + "text": "Submit", + }, + "close": { + "type": "plain_text", + "text": "Cancel", + }, "blocks": [ { "type": "input", "element": {"type": "plain_text_input"}, - "label": {"type": "plain_text", "text": "Label",}, + "label": { + "type": "plain_text", + "text": "Label", + }, } ], }, diff --git a/examples/oauth_app_settings.py b/examples/oauth_app_settings.py index 4975de519..977ec0e49 100644 --- a/examples/oauth_app_settings.py +++ b/examples/oauth_app_settings.py @@ -74,14 +74,26 @@ def test_command(body, respond, client, ack, logger): view={ "type": "modal", "callback_id": "view-id", - "title": {"type": "plain_text", "text": "My App",}, - "submit": {"type": "plain_text", "text": "Submit",}, - "close": {"type": "plain_text", "text": "Cancel",}, + "title": { + "type": "plain_text", + "text": "My App", + }, + "submit": { + "type": "plain_text", + "text": "Submit", + }, + "close": { + "type": "plain_text", + "text": "Cancel", + }, "blocks": [ { "type": "input", "element": {"type": "plain_text_input"}, - "label": {"type": "plain_text", "text": "Label",}, + "label": { + "type": "plain_text", + "text": "Label", + }, } ], }, diff --git a/examples/readme_app.py b/examples/readme_app.py index 6cdbd8ec1..963938658 100644 --- a/examples/readme_app.py +++ b/examples/readme_app.py @@ -34,14 +34,23 @@ def open_modal(ack, client, logger, body): view={ "type": "modal", "callback_id": "view-id", - "title": {"type": "plain_text", "text": "My App",}, - "submit": {"type": "plain_text", "text": "Submit",}, + "title": { + "type": "plain_text", + "text": "My App", + }, + "submit": { + "type": "plain_text", + "text": "Submit", + }, "blocks": [ { "type": "input", "block_id": "b", "element": {"type": "plain_text_input", "action_id": "a"}, - "label": {"type": "plain_text", "text": "Label",}, + "label": { + "type": "plain_text", + "text": "Label", + }, } ], }, diff --git a/examples/readme_async_app.py b/examples/readme_async_app.py index 092dca64b..c43d3af32 100644 --- a/examples/readme_async_app.py +++ b/examples/readme_async_app.py @@ -14,11 +14,13 @@ app = AsyncApp() + @app.command("/hello-bolt-python") async def command(ack, body, respond): await ack() await respond(f"Hi <@{body['user_id']}>!") + # Middleware @app.middleware # or app.use(log_request) async def log_request(logger, body, next): @@ -44,14 +46,23 @@ async def open_modal(ack, client, logger, body): view={ "type": "modal", "callback_id": "view-id", - "title": {"type": "plain_text", "text": "My App",}, - "submit": {"type": "plain_text", "text": "Submit",}, + "title": { + "type": "plain_text", + "text": "My App", + }, + "submit": { + "type": "plain_text", + "text": "Submit", + }, "blocks": [ { "type": "input", "block_id": "b", "element": {"type": "plain_text_input", "action_id": "a"}, - "label": {"type": "plain_text", "text": "Label",}, + "label": { + "type": "plain_text", + "text": "Label", + }, } ], }, diff --git a/examples/sqlalchemy/async_oauth_app.py b/examples/sqlalchemy/async_oauth_app.py index 4aca131de..605e1fb1b 100644 --- a/examples/sqlalchemy/async_oauth_app.py +++ b/examples/sqlalchemy/async_oauth_app.py @@ -157,10 +157,14 @@ async def async_consume(self, state: str) -> bool: ) installation_store = AsyncSQLAlchemyInstallationStore( - client_id=client_id, database_url=database_url, logger=logger, + client_id=client_id, + database_url=database_url, + logger=logger, ) oauth_state_store = AsyncSQLAlchemyOAuthStateStore( - expiration_seconds=120, database_url=database_url, logger=logger, + expiration_seconds=120, + database_url=database_url, + logger=logger, ) app = AsyncApp( @@ -168,7 +172,9 @@ async def async_consume(self, state: str) -> bool: signing_secret=signing_secret, installation_store=installation_store, oauth_settings=AsyncOAuthSettings( - client_id=client_id, client_secret=client_secret, state_store=oauth_state_store, + client_id=client_id, + client_secret=client_secret, + state_store=oauth_state_store, ), ) app_handler = AsyncSlackRequestHandler(app) diff --git a/examples/sqlalchemy/oauth_app.py b/examples/sqlalchemy/oauth_app.py index 40e1309ec..4ad7f8ff3 100644 --- a/examples/sqlalchemy/oauth_app.py +++ b/examples/sqlalchemy/oauth_app.py @@ -25,10 +25,14 @@ engine: Engine = sqlalchemy.create_engine(database_url) installation_store = SQLAlchemyInstallationStore( - client_id=client_id, engine=engine, logger=logger, + client_id=client_id, + engine=engine, + logger=logger, ) oauth_state_store = SQLAlchemyOAuthStateStore( - expiration_seconds=120, engine=engine, logger=logger, + expiration_seconds=120, + engine=engine, + logger=logger, ) try: diff --git a/examples/steps_from_apps.py b/examples/steps_from_apps.py index ab3921062..26cc9665a 100644 --- a/examples/steps_from_apps.py +++ b/examples/steps_from_apps.py @@ -101,7 +101,11 @@ def save(ack: Ack, view: dict, update: Update): }, }, outputs=[ - {"name": "taskName", "type": "text", "label": "Task Name", }, + { + "name": "taskName", + "type": "text", + "label": "Task Name", + }, { "name": "taskDescription", "type": "text", @@ -112,7 +116,7 @@ def save(ack: Ack, view: dict, update: Update): "type": "text", "label": "Task Author Email", }, - ] + ], ) ack() @@ -161,9 +165,7 @@ def execute(step: dict, client: WebClient, complete: Complete, fail: Fail): }, ) except Exception as err: - fail(error={ - "message": "Something wrong!" - }) + fail(error={"message": "Something wrong!"}) app.step( diff --git a/examples/steps_from_apps_primitive.py b/examples/steps_from_apps_primitive.py index 9f8889cbc..efd206eda 100644 --- a/examples/steps_from_apps_primitive.py +++ b/examples/steps_from_apps_primitive.py @@ -104,7 +104,11 @@ def save(ack: Ack, client: WebClient, body: dict): }, }, "outputs": [ - {"name": "taskName", "type": "text", "label": "Task Name",}, + { + "name": "taskName", + "type": "text", + "label": "Task Name", + }, { "name": "taskDescription", "type": "text", diff --git a/setup.py b/setup.py index b049c0102..bf95537e6 100755 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ "pytest-cov>=2,<3", "pytest-asyncio<1", # for async "aiohttp>=3,<4", # for async - "black==19.10b0", # TODO: upgrading the version + "black==20.8b1", ] setuptools.setup( diff --git a/slack_bolt/adapter/aiohttp/__init__.py b/slack_bolt/adapter/aiohttp/__init__.py index 6d4cb9715..02d6a1673 100644 --- a/slack_bolt/adapter/aiohttp/__init__.py +++ b/slack_bolt/adapter/aiohttp/__init__.py @@ -8,7 +8,9 @@ async def to_bolt_request(request: web.Request) -> AsyncBoltRequest: return AsyncBoltRequest( - body=await request.text(), query=request.query_string, headers=request.headers, + body=await request.text(), + query=request.query_string, + headers=request.headers, ) diff --git a/slack_bolt/adapter/aws_lambda/chalice_handler.py b/slack_bolt/adapter/aws_lambda/chalice_handler.py index 48d64ab3a..8d5fc9b21 100644 --- a/slack_bolt/adapter/aws_lambda/chalice_handler.py +++ b/slack_bolt/adapter/aws_lambda/chalice_handler.py @@ -76,14 +76,24 @@ def handle(self, request: Request): def to_bolt_request(request: Request, body: str) -> BoltRequest: - return BoltRequest(body=body, query=request.query_params, headers=request.headers,) + return BoltRequest( + body=body, + query=request.query_params, + headers=request.headers, + ) def to_chalice_response(resp: BoltResponse) -> Response: return Response( - status_code=resp.status, body=resp.body, headers=resp.first_headers(), + status_code=resp.status, + body=resp.body, + headers=resp.first_headers(), ) def not_found() -> Response: - return Response(status_code=404, body="Not Found", headers={},) + return Response( + status_code=404, + body="Not Found", + headers={}, + ) diff --git a/slack_bolt/adapter/aws_lambda/handler.py b/slack_bolt/adapter/aws_lambda/handler.py index 885115cb3..fef64094c 100644 --- a/slack_bolt/adapter/aws_lambda/handler.py +++ b/slack_bolt/adapter/aws_lambda/handler.py @@ -82,7 +82,9 @@ def to_bolt_request(event) -> BoltRequest: headers = event.get("headers", {}) headers["cookie"] = cookies return BoltRequest( - body=body, query=event.get("queryStringParameters", {}), headers=headers, + body=body, + query=event.get("queryStringParameters", {}), + headers=headers, ) diff --git a/slack_bolt/adapter/bottle/handler.py b/slack_bolt/adapter/bottle/handler.py index 4b4d9aef0..d00976c32 100644 --- a/slack_bolt/adapter/bottle/handler.py +++ b/slack_bolt/adapter/bottle/handler.py @@ -10,7 +10,11 @@ def to_bolt_request(req: Request) -> BoltRequest: body = req.body.read() if isinstance(body, bytes): body = body.decode("utf-8") - return BoltRequest(body=body, query=req.query_string, headers=req.headers,) + return BoltRequest( + body=body, + query=req.query_string, + headers=req.headers, + ) def set_response(bolt_resp: BoltResponse, resp: Response) -> None: diff --git a/slack_bolt/adapter/cherrypy/handler.py b/slack_bolt/adapter/cherrypy/handler.py index bd8dd0dc3..aa228f3f8 100644 --- a/slack_bolt/adapter/cherrypy/handler.py +++ b/slack_bolt/adapter/cherrypy/handler.py @@ -11,7 +11,11 @@ def build_bolt_request() -> BoltRequest: req = cherrypy.request body = req.raw_body if hasattr(req, "raw_body") else "" - return BoltRequest(body=body, query=req.query_string, headers=req.headers,) + return BoltRequest( + body=body, + query=req.query_string, + headers=req.headers, + ) def set_response_status_and_headers(bolt_resp: BoltResponse) -> None: diff --git a/slack_bolt/adapter/django/handler.py b/slack_bolt/adapter/django/handler.py index 1749b67de..24eb91b0e 100644 --- a/slack_bolt/adapter/django/handler.py +++ b/slack_bolt/adapter/django/handler.py @@ -11,12 +11,17 @@ def to_bolt_request(req: HttpRequest) -> BoltRequest: raw_body: bytes = req.body body: str = raw_body.decode("utf-8") if raw_body else "" - return BoltRequest(body=body, query=req.META["QUERY_STRING"], headers=req.headers,) + return BoltRequest( + body=body, + query=req.META["QUERY_STRING"], + headers=req.headers, + ) def to_django_response(bolt_resp: BoltResponse) -> HttpResponse: resp: HttpResponse = HttpResponse( - status=bolt_resp.status, content=bolt_resp.body.encode("utf-8"), + status=bolt_resp.status, + content=bolt_resp.body.encode("utf-8"), ) for k, v in bolt_resp.first_headers_without_set_cookie().items(): resp[k] = v diff --git a/slack_bolt/adapter/pyramid/handler.py b/slack_bolt/adapter/pyramid/handler.py index 47fe96645..14ba14c2c 100644 --- a/slack_bolt/adapter/pyramid/handler.py +++ b/slack_bolt/adapter/pyramid/handler.py @@ -15,7 +15,9 @@ def to_bolt_request(request: Request) -> BoltRequest: else: body = request.body bolt_req = BoltRequest( - body=body, query=request.query_string, headers=request.headers, + body=body, + query=request.query_string, + headers=request.headers, ) return bolt_req diff --git a/slack_bolt/adapter/sanic/async_handler.py b/slack_bolt/adapter/sanic/async_handler.py index a18af2250..6b3d20c15 100644 --- a/slack_bolt/adapter/sanic/async_handler.py +++ b/slack_bolt/adapter/sanic/async_handler.py @@ -10,7 +10,9 @@ def to_async_bolt_request(req: Request) -> AsyncBoltRequest: return AsyncBoltRequest( - body=req.body.decode("utf-8"), query=req.query_string, headers=req.headers, + body=req.body.decode("utf-8"), + query=req.query_string, + headers=req.headers, ) @@ -58,4 +60,7 @@ async def handle(self, req: Request) -> HTTPResponse: bolt_resp = await self.app.async_dispatch(to_async_bolt_request(req)) return to_sanic_response(bolt_resp) - return HTTPResponse(status=404, body="Not found",) + return HTTPResponse( + status=404, + body="Not found", + ) diff --git a/slack_bolt/adapter/starlette/async_handler.py b/slack_bolt/adapter/starlette/async_handler.py index a4fc0464b..bc38176bf 100644 --- a/slack_bolt/adapter/starlette/async_handler.py +++ b/slack_bolt/adapter/starlette/async_handler.py @@ -8,7 +8,9 @@ def to_async_bolt_request(req: Request, body: bytes) -> AsyncBoltRequest: return AsyncBoltRequest( - body=body.decode("utf-8"), query=req.query_params, headers=req.headers, + body=body.decode("utf-8"), + query=req.query_params, + headers=req.headers, ) @@ -56,4 +58,7 @@ async def handle(self, req: Request) -> Response: bolt_resp = await self.app.async_dispatch(to_async_bolt_request(req, body)) return to_starlette_response(bolt_resp) - return Response(status_code=404, content="Not found",) + return Response( + status_code=404, + content="Not found", + ) diff --git a/slack_bolt/adapter/starlette/handler.py b/slack_bolt/adapter/starlette/handler.py index e5e4f6057..c8cea10d4 100644 --- a/slack_bolt/adapter/starlette/handler.py +++ b/slack_bolt/adapter/starlette/handler.py @@ -7,7 +7,9 @@ def to_bolt_request(req: Request, body: bytes) -> BoltRequest: return BoltRequest( - body=body.decode("utf-8"), query=req.query_params, headers=req.headers, + body=body.decode("utf-8"), + query=req.query_params, + headers=req.headers, ) @@ -53,4 +55,7 @@ async def handle(self, req: Request) -> Response: bolt_resp = self.app.dispatch(to_bolt_request(req, body)) return to_starlette_response(bolt_resp) - return Response(status_code=404, content="Not found",) + return Response( + status_code=404, + content="Not found", + ) diff --git a/slack_bolt/app/app.py b/slack_bolt/app/app.py index 75593af78..da54e7393 100644 --- a/slack_bolt/app/app.py +++ b/slack_bolt/app/app.py @@ -224,7 +224,8 @@ def __init__( ), listener_executor=listener_executor, lazy_listener_runner=ThreadLazyListenerRunner( - logger=self._framework_logger, executor=listener_executor, + logger=self._framework_logger, + executor=listener_executor, ), ) @@ -306,7 +307,10 @@ def start(self, port: int = 3000, path: str = "/slack/events") -> None: :return: None """ self._development_server = SlackAppDevelopmentServer( - port=port, path=path, app=self, oauth_flow=self.oauth_flow, + port=port, + path=path, + app=self, + oauth_flow=self.oauth_flow, ) self._development_server.start() @@ -411,7 +415,10 @@ def step( step = callback_id if isinstance(callback_id, (str, Pattern)): step = WorkflowStep( - callback_id=callback_id, edit=edit, save=save, execute=execute, + callback_id=callback_id, + edit=edit, + save=save, + execute=execute, ) elif not isinstance(step, WorkflowStep): raise BoltError("Invalid step object") @@ -431,7 +438,8 @@ def error( :return: None """ self._listener_runner.listener_error_handler = CustomListenerErrorHandler( - logger=self._framework_logger, func=func, + logger=self._framework_logger, + func=func, ) return func @@ -864,7 +872,11 @@ def _register_listener( class SlackAppDevelopmentServer: def __init__( - self, port: int, path: str, app: App, oauth_flow: Optional[OAuthFlow] = None, + self, + port: int, + path: str, + app: App, + oauth_flow: Optional[OAuthFlow] = None, ): """Slack App Development Server diff --git a/slack_bolt/app/async_app.py b/slack_bolt/app/async_app.py index 8fdc6bca0..d74ea898d 100644 --- a/slack_bolt/app/async_app.py +++ b/slack_bolt/app/async_app.py @@ -331,7 +331,11 @@ def server( or self._server.port != port or self._server.path != path ): - self._server = AsyncSlackAppServer(port=port, path=path, app=self,) + self._server = AsyncSlackAppServer( + port=port, + path=path, + app=self, + ) return self._server def web_app(self, path: str = "/slack/events") -> web.Application: @@ -461,7 +465,10 @@ def step( step = callback_id if isinstance(callback_id, (str, Pattern)): step = AsyncWorkflowStep( - callback_id=callback_id, edit=edit, save=save, execute=execute, + callback_id=callback_id, + edit=edit, + save=save, + execute=execute, ) elif not isinstance(step, AsyncWorkflowStep): raise BoltError("Invalid step object") @@ -480,8 +487,11 @@ def error( when getting an unhandled error in Bolt app. :return: None """ - self._async_listener_runner.listener_error_handler = AsyncCustomListenerErrorHandler( - logger=self._framework_logger, func=func, + self._async_listener_runner.listener_error_handler = ( + AsyncCustomListenerErrorHandler( + logger=self._framework_logger, + func=func, + ) ) return func diff --git a/slack_bolt/app/async_server.py b/slack_bolt/app/async_server.py index 6ae669098..aeb93fb73 100644 --- a/slack_bolt/app/async_server.py +++ b/slack_bolt/app/async_server.py @@ -14,7 +14,10 @@ class AsyncSlackAppServer: web_app: web.Application def __init__( # type:ignore - self, port: int, path: str, app: "AsyncApp", # type:ignore + self, + port: int, + path: str, + app: "AsyncApp", # type:ignore ): """Standalone AIOHTTP Web Server @@ -67,7 +70,7 @@ async def handle_post_requests(self, request: web.Request) -> web.Response: return await to_aiohttp_response(bolt_resp) def start(self) -> None: - """ Starts a new web server process. + """Starts a new web server process. :return: None """ diff --git a/slack_bolt/authorization/async_authorize.py b/slack_bolt/authorization/async_authorize.py index a78700ced..fb723f3cd 100644 --- a/slack_bolt/authorization/async_authorize.py +++ b/slack_bolt/authorization/async_authorize.py @@ -145,11 +145,13 @@ async def __call__( if installation.user_id != user_id: # try to fetch the request user's installation # to reflect the user's access token if exists - user_installation = await self.installation_store.async_find_installation( - enterprise_id=enterprise_id, - team_id=team_id, - user_id=user_id, - is_enterprise_install=context.is_enterprise_install, + user_installation = ( + await self.installation_store.async_find_installation( + enterprise_id=enterprise_id, + team_id=team_id, + user_id=user_id, + is_enterprise_install=context.is_enterprise_install, + ) ) if user_installation is not None: installation = user_installation diff --git a/slack_bolt/authorization/authorize.py b/slack_bolt/authorization/authorize.py index 7e51ab97b..090d5113f 100644 --- a/slack_bolt/authorization/authorize.py +++ b/slack_bolt/authorization/authorize.py @@ -29,7 +29,10 @@ def __call__( class CallableAuthorize(Authorize): def __init__( - self, *, logger: Logger, func: Callable[..., AuthorizeResult], + self, + *, + logger: Logger, + func: Callable[..., AuthorizeResult], ): self.logger = logger self.func = func diff --git a/slack_bolt/context/say/async_say.py b/slack_bolt/context/say/async_say.py index ccbefd4f9..a47838e1b 100644 --- a/slack_bolt/context/say/async_say.py +++ b/slack_bolt/context/say/async_say.py @@ -12,7 +12,9 @@ class AsyncSay: channel: Optional[str] def __init__( - self, client: Optional[AsyncWebClient], channel: Optional[str], + self, + client: Optional[AsyncWebClient], + channel: Optional[str], ): self.client = client self.channel = channel diff --git a/slack_bolt/context/say/say.py b/slack_bolt/context/say/say.py index 9c4181957..ccf7d6d91 100644 --- a/slack_bolt/context/say/say.py +++ b/slack_bolt/context/say/say.py @@ -13,7 +13,9 @@ class Say: channel: Optional[str] def __init__( - self, client: Optional[WebClient], channel: Optional[str], + self, + client: Optional[WebClient], + channel: Optional[str], ): self.client = client self.channel = channel diff --git a/slack_bolt/lazy_listener/async_runner.py b/slack_bolt/lazy_listener/async_runner.py index d640d48ec..da8712da9 100644 --- a/slack_bolt/lazy_listener/async_runner.py +++ b/slack_bolt/lazy_listener/async_runner.py @@ -31,6 +31,8 @@ async def run( :return: None """ func = to_runnable_function( - internal_func=function, logger=self.logger, request=request, + internal_func=function, + logger=self.logger, + request=request, ) return await func() # type: ignore diff --git a/slack_bolt/lazy_listener/asyncio_runner.py b/slack_bolt/lazy_listener/asyncio_runner.py index f9ceb6cf3..072f3ecc6 100644 --- a/slack_bolt/lazy_listener/asyncio_runner.py +++ b/slack_bolt/lazy_listener/asyncio_runner.py @@ -11,7 +11,8 @@ class AsyncioLazyListenerRunner(AsyncLazyListenerRunner): logger: Logger def __init__( - self, logger: Logger, + self, + logger: Logger, ): self.logger = logger @@ -20,6 +21,8 @@ def start( ) -> None: asyncio.ensure_future( to_runnable_function( - internal_func=function, logger=self.logger, request=request, + internal_func=function, + logger=self.logger, + request=request, ) ) diff --git a/slack_bolt/lazy_listener/internals.py b/slack_bolt/lazy_listener/internals.py index ee6659540..f2934ef69 100644 --- a/slack_bolt/lazy_listener/internals.py +++ b/slack_bolt/lazy_listener/internals.py @@ -8,7 +8,9 @@ def build_runnable_function( - func: Callable[..., None], logger: Logger, request: BoltRequest, + func: Callable[..., None], + logger: Logger, + request: BoltRequest, ) -> Callable[[], None]: arg_names = inspect.getfullargspec(func).args diff --git a/slack_bolt/lazy_listener/runner.py b/slack_bolt/lazy_listener/runner.py index 3442693ea..4fc8bb072 100644 --- a/slack_bolt/lazy_listener/runner.py +++ b/slack_bolt/lazy_listener/runner.py @@ -26,4 +26,8 @@ def run(self, function: Callable[..., None], request: BoltRequest) -> None: :param request: The request to pass to the function. The object must be thread-safe. :return: None """ - build_runnable_function(func=function, logger=self.logger, request=request,)() + build_runnable_function( + func=function, + logger=self.logger, + request=request, + )() diff --git a/slack_bolt/lazy_listener/thread_runner.py b/slack_bolt/lazy_listener/thread_runner.py index c6812a46a..d2e7a09a0 100644 --- a/slack_bolt/lazy_listener/thread_runner.py +++ b/slack_bolt/lazy_listener/thread_runner.py @@ -11,12 +11,18 @@ class ThreadLazyListenerRunner(LazyListenerRunner): logger: Logger def __init__( - self, logger: Logger, executor: ThreadPoolExecutor, + self, + logger: Logger, + executor: ThreadPoolExecutor, ): self.logger = logger self.executor = executor def start(self, function: Callable[..., None], request: BoltRequest) -> None: self.executor.submit( - build_runnable_function(func=function, logger=self.logger, request=request,) + build_runnable_function( + func=function, + logger=self.logger, + request=request, + ) ) diff --git a/slack_bolt/listener/async_listener.py b/slack_bolt/listener/async_listener.py index 7222b80a8..21fe7b033 100644 --- a/slack_bolt/listener/async_listener.py +++ b/slack_bolt/listener/async_listener.py @@ -16,7 +16,10 @@ class AsyncListener(metaclass=ABCMeta): auto_acknowledgement: bool async def async_matches( - self, *, req: AsyncBoltRequest, resp: BoltResponse, + self, + *, + req: AsyncBoltRequest, + resp: BoltResponse, ) -> bool: is_matched: bool = False for matcher in self.matchers: @@ -26,7 +29,10 @@ async def async_matches( return is_matched async def run_async_middleware( - self, *, req: AsyncBoltRequest, resp: BoltResponse, + self, + *, + req: AsyncBoltRequest, + resp: BoltResponse, ) -> Tuple[BoltResponse, bool]: """Runs an async middleware. @@ -100,7 +106,10 @@ def __init__( self.logger = get_bolt_app_logger(app_name, self.ack_function) async def run_ack_function( - self, *, request: AsyncBoltRequest, response: BoltResponse, + self, + *, + request: AsyncBoltRequest, + response: BoltResponse, ) -> Optional[BoltResponse]: return await self.ack_function( **build_async_required_kwargs( diff --git a/slack_bolt/listener/asyncio_runner.py b/slack_bolt/listener/asyncio_runner.py index dca9d5705..c9c1d49fa 100644 --- a/slack_bolt/listener/asyncio_runner.py +++ b/slack_bolt/listener/asyncio_runner.py @@ -62,7 +62,9 @@ async def run( response = BoltResponse(status=500) response.status = 500 await self.listener_error_handler.handle( - error=e, request=request, response=response, + error=e, + request=request, + response=response, ) ack.response = response @@ -95,7 +97,9 @@ async def run( # start the listener function asynchronously # NOTE: intentionally async def run_ack_function_asynchronously( - ack: AsyncAck, request: AsyncBoltRequest, response: BoltResponse, + ack: AsyncAck, + request: AsyncBoltRequest, + response: BoltResponse, ): try: await listener.run_ack_function( @@ -111,7 +115,9 @@ async def run_ack_function_asynchronously( response = None await self.listener_error_handler.handle( - error=e, request=request, response=response, + error=e, + request=request, + response=response, ) ack.response = response diff --git a/slack_bolt/listener/custom_listener.py b/slack_bolt/listener/custom_listener.py index 8e8a54e98..99f8c353f 100644 --- a/slack_bolt/listener/custom_listener.py +++ b/slack_bolt/listener/custom_listener.py @@ -41,7 +41,10 @@ def __init__( self.logger = get_bolt_app_logger(app_name, self.ack_function) def run_ack_function( - self, *, request: BoltRequest, response: BoltResponse, + self, + *, + request: BoltRequest, + response: BoltResponse, ) -> Optional[BoltResponse]: return self.ack_function( **build_required_kwargs( diff --git a/slack_bolt/listener/listener.py b/slack_bolt/listener/listener.py index 6f1d43c9a..748392f94 100644 --- a/slack_bolt/listener/listener.py +++ b/slack_bolt/listener/listener.py @@ -14,7 +14,12 @@ class Listener(metaclass=ABCMeta): lazy_functions: Sequence[Callable[..., None]] auto_acknowledgement: bool - def matches(self, *, req: BoltRequest, resp: BoltResponse,) -> bool: + def matches( + self, + *, + req: BoltRequest, + resp: BoltResponse, + ) -> bool: is_matched: bool = False for matcher in self.matchers: is_matched = matcher.matches(req, resp) @@ -23,7 +28,10 @@ def matches(self, *, req: BoltRequest, resp: BoltResponse,) -> bool: return is_matched def run_middleware( - self, *, req: BoltRequest, resp: BoltResponse, + self, + *, + req: BoltRequest, + resp: BoltResponse, ) -> Tuple[BoltResponse, bool]: """ diff --git a/slack_bolt/listener/listener_error_handler.py b/slack_bolt/listener/listener_error_handler.py index 5854fb356..0747bd368 100644 --- a/slack_bolt/listener/listener_error_handler.py +++ b/slack_bolt/listener/listener_error_handler.py @@ -21,7 +21,10 @@ class ListenerErrorHandler(metaclass=ABCMeta): @abstractmethod def handle( - self, error: Exception, request: BoltRequest, response: Optional[BoltResponse], + self, + error: Exception, + request: BoltRequest, + response: Optional[BoltResponse], ) -> None: """Handles an unhandled exception. @@ -40,7 +43,10 @@ def __init__(self, logger: Logger, func: Callable[..., None]): self.arg_names = inspect.getfullargspec(func).args def handle( - self, error: Exception, request: BoltRequest, response: Optional[BoltResponse], + self, + error: Exception, + request: BoltRequest, + response: Optional[BoltResponse], ): all_available_args = { "logger": self.logger, @@ -95,7 +101,10 @@ def __init__(self, logger: Logger): self.logger = logger def handle( - self, error: Exception, request: BoltRequest, response: Optional[BoltResponse], + self, + error: Exception, + request: BoltRequest, + response: Optional[BoltResponse], ): message = f"Failed to run listener function (error: {error})" self.logger.exception(message) diff --git a/slack_bolt/listener/thread_runner.py b/slack_bolt/listener/thread_runner.py index dfe2a51a3..28d4051da 100644 --- a/slack_bolt/listener/thread_runner.py +++ b/slack_bolt/listener/thread_runner.py @@ -63,7 +63,9 @@ def run( # type: ignore response = BoltResponse(status=500) response.status = 500 self.listener_error_handler.handle( - error=e, request=request, response=response, + error=e, + request=request, + response=response, ) ack.response = response @@ -103,7 +105,9 @@ def run_ack_function_asynchronously(): # You can customize this by passing your own error handler. if listener.auto_acknowledgement: self.listener_error_handler.handle( - error=e, request=request, response=response, + error=e, + request=request, + response=response, ) else: if response is None: @@ -112,7 +116,9 @@ def run_ack_function_asynchronously(): if ack.response is not None: # already acknowledged response = None self.listener_error_handler.handle( - error=e, request=request, response=response, + error=e, + request=request, + response=response, ) ack.response = response diff --git a/slack_bolt/listener_matcher/builtins.py b/slack_bolt/listener_matcher/builtins.py index fce9031b1..bcba2a043 100644 --- a/slack_bolt/listener_matcher/builtins.py +++ b/slack_bolt/listener_matcher/builtins.py @@ -55,7 +55,8 @@ def matches(self, req: BoltRequest, resp: BoltResponse) -> bool: def build_listener_matcher( - func: Callable[..., bool], asyncio: bool, + func: Callable[..., bool], + asyncio: bool, ) -> Union[ListenerMatcher, "AsyncListenerMatcher"]: if asyncio: from .async_builtins import AsyncBuiltinListenerMatcher @@ -73,7 +74,8 @@ async def async_fun(body: Dict[str, Any]) -> bool: def event( - constraints: Union[str, Pattern, Dict[str, str]], asyncio: bool = False, + constraints: Union[str, Pattern, Dict[str, str]], + asyncio: bool = False, ) -> Union[ListenerMatcher, "AsyncListenerMatcher"]: if isinstance(constraints, (str, Pattern)): event_type: Union[str, Pattern] = constraints @@ -110,7 +112,8 @@ def func(body: Dict[str, Any]) -> bool: def workflow_step_execute( - callback_id: Union[str, Pattern], asyncio: bool = False, + callback_id: Union[str, Pattern], + asyncio: bool = False, ) -> Union[ListenerMatcher, "AsyncListenerMatcher"]: def func(body: Dict[str, Any]) -> bool: return ( @@ -128,7 +131,8 @@ def func(body: Dict[str, Any]) -> bool: def command( - command: Union[str, Pattern], asyncio: bool = False, + command: Union[str, Pattern], + asyncio: bool = False, ) -> Union[ListenerMatcher, "AsyncListenerMatcher"]: def func(body: Dict[str, Any]) -> bool: return is_slash_command(body) and _matches(command, body["command"]) @@ -164,7 +168,8 @@ def func(body: Dict[str, Any]) -> bool: def global_shortcut( - callback_id: Union[str, Pattern], asyncio: bool = False, + callback_id: Union[str, Pattern], + asyncio: bool = False, ) -> Union[ListenerMatcher, "AsyncListenerMatcher"]: def func(body: Dict[str, Any]) -> bool: return is_global_shortcut(body) and _matches(callback_id, body["callback_id"]) @@ -173,7 +178,8 @@ def func(body: Dict[str, Any]) -> bool: def message_shortcut( - callback_id: Union[str, Pattern], asyncio: bool = False, + callback_id: Union[str, Pattern], + asyncio: bool = False, ) -> Union[ListenerMatcher, "AsyncListenerMatcher"]: def func(body: Dict[str, Any]) -> bool: return is_message_shortcut(body) and _matches(callback_id, body["callback_id"]) @@ -257,12 +263,16 @@ def func(body: Dict[str, Any]) -> bool: return build_listener_matcher(func, asyncio) -def _attachment_action(callback_id: Union[str, Pattern], body: Dict[str, Any],) -> bool: +def _attachment_action( + callback_id: Union[str, Pattern], + body: Dict[str, Any], +) -> bool: return is_attachment_action(body) and _matches(callback_id, body["callback_id"]) def attachment_action( - callback_id: Union[str, Pattern], asyncio: bool = False, + callback_id: Union[str, Pattern], + asyncio: bool = False, ) -> Union[ListenerMatcher, "AsyncListenerMatcher"]: def func(body: Dict[str, Any]) -> bool: return _attachment_action(callback_id, body) @@ -270,12 +280,16 @@ def func(body: Dict[str, Any]) -> bool: return build_listener_matcher(func, asyncio) -def _dialog_submission(callback_id: Union[str, Pattern], body: Dict[str, Any],) -> bool: +def _dialog_submission( + callback_id: Union[str, Pattern], + body: Dict[str, Any], +) -> bool: return is_dialog_submission(body) and _matches(callback_id, body["callback_id"]) def dialog_submission( - callback_id: Union[str, Pattern], asyncio: bool = False, + callback_id: Union[str, Pattern], + asyncio: bool = False, ) -> Union[ListenerMatcher, "AsyncListenerMatcher"]: def func(body: Dict[str, Any]) -> bool: return _dialog_submission(callback_id, body) @@ -284,13 +298,15 @@ def func(body: Dict[str, Any]) -> bool: def _dialog_cancellation( - callback_id: Union[str, Pattern], body: Dict[str, Any], + callback_id: Union[str, Pattern], + body: Dict[str, Any], ) -> bool: return is_dialog_cancellation(body) and _matches(callback_id, body["callback_id"]) def dialog_cancellation( - callback_id: Union[str, Pattern], asyncio: bool = False, + callback_id: Union[str, Pattern], + asyncio: bool = False, ) -> Union[ListenerMatcher, "AsyncListenerMatcher"]: def func(body: Dict[str, Any]) -> bool: return _dialog_cancellation(callback_id, body) @@ -299,13 +315,15 @@ def func(body: Dict[str, Any]) -> bool: def _workflow_step_edit( - callback_id: Union[str, Pattern], body: Dict[str, Any], + callback_id: Union[str, Pattern], + body: Dict[str, Any], ) -> bool: return is_workflow_step_edit(body) and _matches(callback_id, body["callback_id"]) def workflow_step_edit( - callback_id: Union[str, Pattern], asyncio: bool = False, + callback_id: Union[str, Pattern], + asyncio: bool = False, ) -> Union[ListenerMatcher, "AsyncListenerMatcher"]: def func(body: Dict[str, Any]) -> bool: return _workflow_step_edit(callback_id, body) @@ -335,7 +353,8 @@ def view( def view_submission( - callback_id: Union[str, Pattern], asyncio: bool = False, + callback_id: Union[str, Pattern], + asyncio: bool = False, ) -> Union[ListenerMatcher, "AsyncListenerMatcher"]: def func(body: Dict[str, Any]) -> bool: return is_view_submission(body) and _matches( @@ -346,7 +365,8 @@ def func(body: Dict[str, Any]) -> bool: def view_closed( - callback_id: Union[str, Pattern], asyncio: bool = False, + callback_id: Union[str, Pattern], + asyncio: bool = False, ) -> Union[ListenerMatcher, "AsyncListenerMatcher"]: def func(body: Dict[str, Any]) -> bool: return is_view_closed(body) and _matches( @@ -357,7 +377,8 @@ def func(body: Dict[str, Any]) -> bool: def workflow_step_save( - callback_id: Union[str, Pattern], asyncio: bool = False, + callback_id: Union[str, Pattern], + asyncio: bool = False, ) -> Union[ListenerMatcher, "AsyncListenerMatcher"]: def func(body: Dict[str, Any]) -> bool: return is_workflow_step_save(body) and _matches( @@ -394,12 +415,16 @@ def func(body: Dict[str, Any]) -> bool: ) -def _block_suggestion(action_id: Union[str, Pattern], body: Dict[str, Any],) -> bool: +def _block_suggestion( + action_id: Union[str, Pattern], + body: Dict[str, Any], +) -> bool: return is_block_suggestion(body) and _matches(action_id, body["action_id"]) def block_suggestion( - action_id: Union[str, Pattern], asyncio: bool = False, + action_id: Union[str, Pattern], + asyncio: bool = False, ) -> Union[ListenerMatcher, "AsyncListenerMatcher"]: def func(body: Dict[str, Any]) -> bool: return _block_suggestion(action_id, body) @@ -407,12 +432,16 @@ def func(body: Dict[str, Any]) -> bool: return build_listener_matcher(func, asyncio) -def _dialog_suggestion(callback_id: Union[str, Pattern], body: Dict[str, Any],) -> bool: +def _dialog_suggestion( + callback_id: Union[str, Pattern], + body: Dict[str, Any], +) -> bool: return is_dialog_suggestion(body) and _matches(callback_id, body["callback_id"]) def dialog_suggestion( - callback_id: Union[str, Pattern], asyncio: bool = False, + callback_id: Union[str, Pattern], + asyncio: bool = False, ) -> Union[ListenerMatcher, "AsyncListenerMatcher"]: def func(body: Dict[str, Any]) -> bool: return _dialog_suggestion(callback_id, body) diff --git a/slack_bolt/middleware/authorization/async_internals.py b/slack_bolt/middleware/authorization/async_internals.py index 6a9d1b696..462e39836 100644 --- a/slack_bolt/middleware/authorization/async_internals.py +++ b/slack_bolt/middleware/authorization/async_internals.py @@ -23,5 +23,6 @@ def _is_no_auth_required(req: AsyncBoltRequest) -> bool: def _build_error_response() -> BoltResponse: # show an ephemeral message to the end-user return BoltResponse( - status=200, body=":x: Please install this app into the workspace :bow:", + status=200, + body=":x: Please install this app into the workspace :bow:", ) diff --git a/slack_bolt/middleware/authorization/internals.py b/slack_bolt/middleware/authorization/internals.py index cede00c42..42e958378 100644 --- a/slack_bolt/middleware/authorization/internals.py +++ b/slack_bolt/middleware/authorization/internals.py @@ -52,7 +52,8 @@ def _is_no_auth_test_call_required(req: Union[BoltRequest, "AsyncBoltRequest"]) def _build_error_response() -> BoltResponse: # show an ephemeral message to the end-user return BoltResponse( - status=200, body=":x: Please install this app into the workspace :bow:", + status=200, + body=":x: Please install this app into the workspace :bow:", ) diff --git a/slack_bolt/middleware/authorization/multi_teams_authorization.py b/slack_bolt/middleware/authorization/multi_teams_authorization.py index 5a130d623..20b31836a 100644 --- a/slack_bolt/middleware/authorization/multi_teams_authorization.py +++ b/slack_bolt/middleware/authorization/multi_teams_authorization.py @@ -19,7 +19,9 @@ class MultiTeamsAuthorization(Authorization): authorize: Authorize def __init__( - self, *, authorize: Authorize, + self, + *, + authorize: Authorize, ): """Multi-workspace authorization. @@ -29,7 +31,11 @@ def __init__( self.logger = get_bolt_logger(MultiTeamsAuthorization) def process( - self, *, req: BoltRequest, resp: BoltResponse, next: Callable[[], BoltResponse], + self, + *, + req: BoltRequest, + resp: BoltResponse, + next: Callable[[], BoltResponse], ) -> BoltResponse: if _is_no_auth_required(req): return next() diff --git a/slack_bolt/middleware/authorization/single_team_authorization.py b/slack_bolt/middleware/authorization/single_team_authorization.py index e09d399ab..9ca5b0541 100644 --- a/slack_bolt/middleware/authorization/single_team_authorization.py +++ b/slack_bolt/middleware/authorization/single_team_authorization.py @@ -25,7 +25,11 @@ def __init__(self, *, auth_test_result: Optional[SlackResponse] = None): self.logger = get_bolt_logger(SingleTeamAuthorization) def process( - self, *, req: BoltRequest, resp: BoltResponse, next: Callable[[], BoltResponse], + self, + *, + req: BoltRequest, + resp: BoltResponse, + next: Callable[[], BoltResponse], ) -> BoltResponse: if _is_no_auth_required(req): return next() diff --git a/slack_bolt/middleware/custom_middleware.py b/slack_bolt/middleware/custom_middleware.py index 61b71bac2..016b42ee9 100644 --- a/slack_bolt/middleware/custom_middleware.py +++ b/slack_bolt/middleware/custom_middleware.py @@ -22,7 +22,11 @@ def __init__(self, *, app_name: str, func: Callable): self.logger = get_bolt_app_logger(self.app_name, self.func) def process( - self, *, req: BoltRequest, resp: BoltResponse, next: Callable[[], BoltResponse], + self, + *, + req: BoltRequest, + resp: BoltResponse, + next: Callable[[], BoltResponse], ) -> BoltResponse: return self.func( **build_required_kwargs( diff --git a/slack_bolt/middleware/ignoring_self_events/ignoring_self_events.py b/slack_bolt/middleware/ignoring_self_events/ignoring_self_events.py index dd9eb93a4..06642b301 100644 --- a/slack_bolt/middleware/ignoring_self_events/ignoring_self_events.py +++ b/slack_bolt/middleware/ignoring_self_events/ignoring_self_events.py @@ -14,7 +14,11 @@ def __init__(self): self.logger = get_bolt_logger(IgnoringSelfEvents) def process( - self, *, req: BoltRequest, resp: BoltResponse, next: Callable[[], BoltResponse], + self, + *, + req: BoltRequest, + resp: BoltResponse, + next: Callable[[], BoltResponse], ) -> BoltResponse: auth_result = req.context.authorize_result if self._is_self_event(auth_result, req.context.user_id, req.body): diff --git a/slack_bolt/middleware/message_listener_matches/message_listener_matches.py b/slack_bolt/middleware/message_listener_matches/message_listener_matches.py index 834ab7b4b..41905b381 100644 --- a/slack_bolt/middleware/message_listener_matches/message_listener_matches.py +++ b/slack_bolt/middleware/message_listener_matches/message_listener_matches.py @@ -12,7 +12,11 @@ def __init__(self, keyword: Union[str, Pattern]): self.keyword = keyword def process( - self, *, req: BoltRequest, resp: BoltResponse, next: Callable[[], BoltResponse], + self, + *, + req: BoltRequest, + resp: BoltResponse, + next: Callable[[], BoltResponse], ) -> BoltResponse: text = req.body.get("event", {}).get("text", "") if text: diff --git a/slack_bolt/middleware/middleware.py b/slack_bolt/middleware/middleware.py index 8ecc20ce0..d8c5c4df6 100644 --- a/slack_bolt/middleware/middleware.py +++ b/slack_bolt/middleware/middleware.py @@ -8,7 +8,11 @@ class Middleware(metaclass=ABCMeta): @abstractmethod def process( - self, *, req: BoltRequest, resp: BoltResponse, next: Callable[[], BoltResponse], + self, + *, + req: BoltRequest, + resp: BoltResponse, + next: Callable[[], BoltResponse], ) -> BoltResponse: raise NotImplementedError() diff --git a/slack_bolt/middleware/request_verification/request_verification.py b/slack_bolt/middleware/request_verification/request_verification.py index 538441070..4bca8b643 100644 --- a/slack_bolt/middleware/request_verification/request_verification.py +++ b/slack_bolt/middleware/request_verification/request_verification.py @@ -19,7 +19,11 @@ def __init__(self, signing_secret: str): self.logger = get_bolt_logger(RequestVerification) def process( - self, *, req: BoltRequest, resp: BoltResponse, next: Callable[[], BoltResponse], + self, + *, + req: BoltRequest, + resp: BoltResponse, + next: Callable[[], BoltResponse], ) -> BoltResponse: if self._can_skip(req.mode, req.body): return next() diff --git a/slack_bolt/middleware/ssl_check/ssl_check.py b/slack_bolt/middleware/ssl_check/ssl_check.py index 43d4eca5d..3b4849ed6 100644 --- a/slack_bolt/middleware/ssl_check/ssl_check.py +++ b/slack_bolt/middleware/ssl_check/ssl_check.py @@ -18,7 +18,11 @@ def __init__(self, verification_token: str = None): self.logger = get_bolt_logger(SslCheck) def process( - self, *, req: BoltRequest, resp: BoltResponse, next: Callable[[], BoltResponse], + self, + *, + req: BoltRequest, + resp: BoltResponse, + next: Callable[[], BoltResponse], ) -> BoltResponse: if self._is_ssl_check_request(req.body): if self._verify_token_if_needed(req.body): diff --git a/slack_bolt/middleware/url_verification/url_verification.py b/slack_bolt/middleware/url_verification/url_verification.py index 04e95d2fd..1d1f7b2b4 100644 --- a/slack_bolt/middleware/url_verification/url_verification.py +++ b/slack_bolt/middleware/url_verification/url_verification.py @@ -15,7 +15,11 @@ def __init__(self): self.logger = get_bolt_logger(UrlVerification) def process( - self, *, req: BoltRequest, resp: BoltResponse, next: Callable[[], BoltResponse], + self, + *, + req: BoltRequest, + resp: BoltResponse, + next: Callable[[], BoltResponse], ) -> BoltResponse: if self._is_url_verification_request(req.body): return self._build_success_response(req.body) diff --git a/slack_bolt/oauth/async_callback_options.py b/slack_bolt/oauth/async_callback_options.py index 24c453b53..1ba66dccb 100644 --- a/slack_bolt/oauth/async_callback_options.py +++ b/slack_bolt/oauth/async_callback_options.py @@ -98,10 +98,13 @@ def __init__( async def _success_handler(self, args: AsyncSuccessArgs) -> BoltResponse: return self._response_builder._build_callback_success_response( - request=args.request, installation=args.installation, + request=args.request, + installation=args.installation, ) async def _failure_handler(self, args: AsyncFailureArgs) -> BoltResponse: return self._response_builder._build_callback_failure_response( - request=args.request, reason=args.reason, status=args.suggested_status_code, + request=args.request, + reason=args.reason, + status=args.suggested_status_code, ) diff --git a/slack_bolt/oauth/async_oauth_flow.py b/slack_bolt/oauth/async_oauth_flow.py index d860d8dc7..233c7d149 100644 --- a/slack_bolt/oauth/async_oauth_flow.py +++ b/slack_bolt/oauth/async_oauth_flow.py @@ -139,7 +139,9 @@ def sqlite3( failure_url=failure_url, # Installation Management installation_store=SQLite3InstallationStore( - database=database, client_id=client_id, logger=logger, + database=database, + client_id=client_id, + logger=logger, ), installation_store_bot_only=installation_store_bot_only, # state parameter related configurations @@ -292,14 +294,14 @@ async def run_installation(self, code: str) -> Optional[Installation]: client_secret=self.settings.client_secret, redirect_uri=self.settings.redirect_uri, # can be None ) - installed_enterprise: Dict[str, str] = oauth_response.get( - "enterprise" - ) or {} + installed_enterprise: Dict[str, str] = ( + oauth_response.get("enterprise") or {} + ) installed_team: Dict[str, str] = oauth_response.get("team") or {} installer: Dict[str, str] = oauth_response.get("authed_user") or {} - incoming_webhook: Dict[str, str] = oauth_response.get( - "incoming_webhook" - ) or {} + incoming_webhook: Dict[str, str] = ( + oauth_response.get("incoming_webhook") or {} + ) bot_token: Optional[str] = oauth_response.get("access_token") # NOTE: oauth.v2.access doesn't include bot_id in response diff --git a/slack_bolt/oauth/async_oauth_settings.py b/slack_bolt/oauth/async_oauth_settings.py index 8e36baf2d..fec1bef80 100644 --- a/slack_bolt/oauth/async_oauth_settings.py +++ b/slack_bolt/oauth/async_oauth_settings.py @@ -140,7 +140,8 @@ def __init__( ) # state parameter related configurations self.state_store = state_store or FileOAuthStateStore( - expiration_seconds=state_expiration_seconds, client_id=client_id, + expiration_seconds=state_expiration_seconds, + client_id=client_id, ) self.state_cookie_name = state_cookie_name self.state_expiration_seconds = state_expiration_seconds diff --git a/slack_bolt/oauth/callback_options.py b/slack_bolt/oauth/callback_options.py index 52a87659c..a8efa8a69 100644 --- a/slack_bolt/oauth/callback_options.py +++ b/slack_bolt/oauth/callback_options.py @@ -103,10 +103,13 @@ def __init__( def _success_handler(self, args: SuccessArgs) -> BoltResponse: return self._response_builder._build_callback_success_response( - request=args.request, installation=args.installation, + request=args.request, + installation=args.installation, ) def _failure_handler(self, args: FailureArgs) -> BoltResponse: return self._response_builder._build_callback_failure_response( - request=args.request, reason=args.reason, status=args.suggested_status_code, + request=args.request, + reason=args.reason, + status=args.suggested_status_code, ) diff --git a/slack_bolt/oauth/oauth_flow.py b/slack_bolt/oauth/oauth_flow.py index d68b9d73c..3182c255b 100644 --- a/slack_bolt/oauth/oauth_flow.py +++ b/slack_bolt/oauth/oauth_flow.py @@ -134,7 +134,9 @@ def sqlite3( authorization_url=authorization_url, # Installation Management installation_store=SQLite3InstallationStore( - database=database, client_id=client_id, logger=logger, + database=database, + client_id=client_id, + logger=logger, ), installation_store_bot_only=installation_store_bot_only, # state parameter related configurations @@ -287,17 +289,17 @@ def run_installation(self, code: str) -> Optional[Installation]: client_secret=self.settings.client_secret, redirect_uri=self.settings.redirect_uri, # can be None ) - installed_enterprise: Dict[str, str] = oauth_response.get( - "enterprise" - ) or {} - is_enterprise_install: bool = oauth_response.get( - "is_enterprise_install" - ) or False + installed_enterprise: Dict[str, str] = ( + oauth_response.get("enterprise") or {} + ) + is_enterprise_install: bool = ( + oauth_response.get("is_enterprise_install") or False + ) installed_team: Dict[str, str] = oauth_response.get("team") or {} installer: Dict[str, str] = oauth_response.get("authed_user") or {} - incoming_webhook: Dict[str, str] = oauth_response.get( - "incoming_webhook" - ) or {} + incoming_webhook: Dict[str, str] = ( + oauth_response.get("incoming_webhook") or {} + ) bot_token: Optional[str] = oauth_response.get("access_token") # NOTE: oauth.v2.access doesn't include bot_id in response diff --git a/slack_bolt/oauth/oauth_settings.py b/slack_bolt/oauth/oauth_settings.py index 66ff03260..6010e5c26 100644 --- a/slack_bolt/oauth/oauth_settings.py +++ b/slack_bolt/oauth/oauth_settings.py @@ -134,7 +134,8 @@ def __init__( ) # state parameter related configurations self.state_store = state_store or FileOAuthStateStore( - expiration_seconds=state_expiration_seconds, client_id=client_id, + expiration_seconds=state_expiration_seconds, + client_id=client_id, ) self.state_cookie_name = state_cookie_name self.state_expiration_seconds = state_expiration_seconds diff --git a/slack_bolt/request/async_internals.py b/slack_bolt/request/async_internals.py index c87707ac1..19c20dd02 100644 --- a/slack_bolt/request/async_internals.py +++ b/slack_bolt/request/async_internals.py @@ -10,7 +10,8 @@ def build_async_context( - context: AsyncBoltContext, payload: Dict[str, Any], + context: AsyncBoltContext, + payload: Dict[str, Any], ) -> AsyncBoltContext: enterprise_id = extract_enterprise_id(payload) if enterprise_id: diff --git a/slack_bolt/util/async_utils.py b/slack_bolt/util/async_utils.py index 3713f83e6..60bbe0903 100644 --- a/slack_bolt/util/async_utils.py +++ b/slack_bolt/util/async_utils.py @@ -6,4 +6,7 @@ def create_async_web_client(token: Optional[str] = None) -> AsyncWebClient: - return AsyncWebClient(token=token, user_agent_prefix=f"Bolt-Async/{bolt_version}",) + return AsyncWebClient( + token=token, + user_agent_prefix=f"Bolt-Async/{bolt_version}", + ) diff --git a/slack_bolt/util/utils.py b/slack_bolt/util/utils.py index 4cdc39190..e52a53674 100644 --- a/slack_bolt/util/utils.py +++ b/slack_bolt/util/utils.py @@ -10,7 +10,10 @@ def create_web_client(token: Optional[str] = None) -> WebClient: - return WebClient(token=token, user_agent_prefix=f"Bolt/{bolt_version}",) + return WebClient( + token=token, + user_agent_prefix=f"Bolt/{bolt_version}", + ) def convert_to_dict_list(objects: Sequence[Union[Dict, JsonObject]]) -> Sequence[Dict]: diff --git a/slack_bolt/workflows/step/async_step.py b/slack_bolt/workflows/step/async_step.py index 3044ca513..a8b4573d7 100644 --- a/slack_bolt/workflows/step/async_step.py +++ b/slack_bolt/workflows/step/async_step.py @@ -47,7 +47,11 @@ def __init__( @classmethod def _build_listener( - cls, callback_id: str, app_name: str, listener: AsyncListener, name: str, + cls, + callback_id: str, + app_name: str, + listener: AsyncListener, + name: str, ) -> AsyncListener: if isinstance(listener, AsyncListener): return listener @@ -114,7 +118,9 @@ async def edit_listener_middleware( next: Callable[[], Awaitable[BoltResponse]], ): context["configure"] = AsyncConfigure( - callback_id=callback_id, client=client, body=body, + callback_id=callback_id, + client=client, + body=body, ) return await next() @@ -133,7 +139,10 @@ async def save_listener_middleware( body: dict, next: Callable[[], Awaitable[BoltResponse]], ): - context["update"] = AsyncUpdate(client=client, body=body,) + context["update"] = AsyncUpdate( + client=client, + body=body, + ) return await next() return AsyncCustomMiddleware(app_name=__name__, func=save_listener_middleware) @@ -151,8 +160,14 @@ async def execute_listener_middleware( body: dict, next: Callable[[], Awaitable[BoltResponse]], ): - context["complete"] = AsyncComplete(client=client, body=body,) - context["fail"] = AsyncFail(client=client, body=body,) + context["complete"] = AsyncComplete( + client=client, + body=body, + ) + context["fail"] = AsyncFail( + client=client, + body=body, + ) return await next() return AsyncCustomMiddleware(app_name=__name__, func=execute_listener_middleware) diff --git a/slack_bolt/workflows/step/async_step_middleware.py b/slack_bolt/workflows/step/async_step_middleware.py index cac50d3b0..c1583aa2f 100644 --- a/slack_bolt/workflows/step/async_step_middleware.py +++ b/slack_bolt/workflows/step/async_step_middleware.py @@ -37,7 +37,10 @@ async def async_process( return await next() async def _run( - self, listener: AsyncListener, req: AsyncBoltRequest, resp: BoltResponse, + self, + listener: AsyncListener, + req: AsyncBoltRequest, + resp: BoltResponse, ) -> Optional[BoltResponse]: resp, next_was_not_called = await listener.run_async_middleware( req=req, resp=resp diff --git a/slack_bolt/workflows/step/step.py b/slack_bolt/workflows/step/step.py index d9e562885..0e1954294 100644 --- a/slack_bolt/workflows/step/step.py +++ b/slack_bolt/workflows/step/step.py @@ -115,7 +115,9 @@ def edit_listener_middleware( next: Callable[[], BoltResponse], ): context["configure"] = Configure( - callback_id=callback_id, client=client, body=body, + callback_id=callback_id, + client=client, + body=body, ) return next() @@ -134,7 +136,10 @@ def save_listener_middleware( body: dict, next: Callable[[], BoltResponse], ): - context["update"] = Update(client=client, body=body,) + context["update"] = Update( + client=client, + body=body, + ) return next() return CustomMiddleware(app_name=__name__, func=save_listener_middleware) @@ -152,8 +157,14 @@ def execute_listener_middleware( body: dict, next: Callable[[], BoltResponse], ): - context["complete"] = Complete(client=client, body=body,) - context["fail"] = Fail(client=client, body=body,) + context["complete"] = Complete( + client=client, + body=body, + ) + context["fail"] = Fail( + client=client, + body=body, + ) return next() return CustomMiddleware(app_name=__name__, func=execute_listener_middleware) diff --git a/slack_bolt/workflows/step/step_middleware.py b/slack_bolt/workflows/step/step_middleware.py index 2cbaac772..6c86b26fc 100644 --- a/slack_bolt/workflows/step/step_middleware.py +++ b/slack_bolt/workflows/step/step_middleware.py @@ -14,7 +14,11 @@ def __init__(self, step: WorkflowStep, listener_runner: ThreadListenerRunner): self.listener_runner = listener_runner def process( - self, *, req: BoltRequest, resp: BoltResponse, next: Callable[[], BoltResponse], + self, + *, + req: BoltRequest, + resp: BoltResponse, + next: Callable[[], BoltResponse], ) -> BoltResponse: if self.step.edit.matches(req=req, resp=resp): @@ -33,7 +37,10 @@ def process( return next() def _run( - self, listener: Listener, req: BoltRequest, resp: BoltResponse, + self, + listener: Listener, + req: BoltRequest, + resp: BoltResponse, ) -> Optional[BoltResponse]: resp, next_was_not_called = listener.run_middleware(req=req, resp=resp) if next_was_not_called: diff --git a/slack_bolt/workflows/step/utilities/async_configure.py b/slack_bolt/workflows/step/utilities/async_configure.py index f6a73dfe4..9914f3dc7 100644 --- a/slack_bolt/workflows/step/utilities/async_configure.py +++ b/slack_bolt/workflows/step/utilities/async_configure.py @@ -11,7 +11,9 @@ def __init__(self, *, callback_id: str, client: AsyncWebClient, body: dict): self.body = body async def __call__( - self, *, blocks: Optional[Sequence[Union[dict, Block]]] = None, + self, + *, + blocks: Optional[Sequence[Union[dict, Block]]] = None, ) -> None: await self.client.views_open( trigger_id=self.body["trigger_id"], diff --git a/slack_bolt/workflows/step/utilities/async_fail.py b/slack_bolt/workflows/step/utilities/async_fail.py index f2c6b1de4..e1d277ff4 100644 --- a/slack_bolt/workflows/step/utilities/async_fail.py +++ b/slack_bolt/workflows/step/utilities/async_fail.py @@ -6,7 +6,11 @@ def __init__(self, *, client: AsyncWebClient, body: dict): self.client = client self.body = body - async def __call__(self, *, error: dict,) -> None: + async def __call__( + self, + *, + error: dict, + ) -> None: await self.client.workflows_stepFailed( workflow_step_execute_id=self.body["event"]["workflow_step"][ "workflow_step_execute_id" diff --git a/slack_bolt/workflows/step/utilities/fail.py b/slack_bolt/workflows/step/utilities/fail.py index 6b82dc272..b2c3c4239 100644 --- a/slack_bolt/workflows/step/utilities/fail.py +++ b/slack_bolt/workflows/step/utilities/fail.py @@ -6,7 +6,11 @@ def __init__(self, *, client: WebClient, body: dict): self.client = client self.body = body - def __call__(self, *, error: dict,) -> None: + def __call__( + self, + *, + error: dict, + ) -> None: self.client.workflows_stepFailed( workflow_step_execute_id=self.body["event"]["workflow_step"][ "workflow_step_execute_id" diff --git a/tests/adapter_tests/test_aws_chalice.py b/tests/adapter_tests/test_aws_chalice.py index a9f4912f7..ee80f62dd 100644 --- a/tests/adapter_tests/test_aws_chalice.py +++ b/tests/adapter_tests/test_aws_chalice.py @@ -40,7 +40,8 @@ def teardown_method(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -60,7 +61,10 @@ def test_not_found(self): assert response.status_code == 404 def test_events(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) @app.event("app_mention") def event_handler(): @@ -109,7 +113,10 @@ def events() -> Response: assert self.mock_received_requests["/auth.test"] == 1 def test_shortcuts(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) @app.shortcut("test-shortcut") def shortcut_handler(ack): @@ -153,7 +160,10 @@ def events() -> Response: assert self.mock_received_requests["/auth.test"] == 1 def test_commands(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) @app.command("/hello-world") def command_handler(ack): @@ -197,7 +207,10 @@ def events() -> Response: assert self.mock_received_requests["/auth.test"] == 1 def test_lazy_listeners(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) def command_handler(ack): ack() diff --git a/tests/adapter_tests/test_aws_lambda.py b/tests/adapter_tests/test_aws_lambda.py index d2e638efd..0c05e07d6 100644 --- a/tests/adapter_tests/test_aws_lambda.py +++ b/tests/adapter_tests/test_aws_lambda.py @@ -30,7 +30,10 @@ class TestAWSLambda: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) context = LambdaContext(function_name="test-function") @@ -44,7 +47,8 @@ def teardown_method(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -70,13 +74,19 @@ def test_first_value(self): @mock_lambda def test_clear_all_log_handlers(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) handler = SlackRequestHandler(app) handler.clear_all_log_handlers() @mock_lambda def test_events(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) def event_handler(): pass @@ -128,7 +138,10 @@ def event_handler(): @mock_lambda def test_shortcuts(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) def shortcut_handler(ack): ack() @@ -175,7 +188,10 @@ def shortcut_handler(ack): @mock_lambda def test_commands(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) def command_handler(ack): ack() @@ -222,7 +238,10 @@ def command_handler(ack): @mock_lambda def test_lazy_listeners(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) def command_handler(ack): ack() diff --git a/tests/adapter_tests/test_bottle.py b/tests/adapter_tests/test_bottle.py index 7cb8dffa0..2cfd5a7fb 100644 --- a/tests/adapter_tests/test_bottle.py +++ b/tests/adapter_tests/test_bottle.py @@ -48,8 +48,14 @@ def setup_method(self): self.old_os_env = remove_os_env_temporarily() setup_mock_web_api_server(self) - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) - app = App(client=web_client, signing_secret=signing_secret,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) + app = App( + client=web_client, + signing_secret=signing_secret, + ) TestBottle.handler = SlackRequestHandler(app) app.event("app_mention")(event_handler) app.shortcut("test-shortcut")(shortcut_handler) @@ -61,7 +67,8 @@ def teardown_method(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): diff --git a/tests/adapter_tests/test_bottle_oauth.py b/tests/adapter_tests/test_bottle_oauth.py index 37fd6b25d..52ff7a2ae 100644 --- a/tests/adapter_tests/test_bottle_oauth.py +++ b/tests/adapter_tests/test_bottle_oauth.py @@ -6,7 +6,9 @@ app = App( signing_secret=signing_secret, oauth_settings=OAuthSettings( - client_id="111.111", client_secret="xxx", scopes=["chat:write", "commands"], + client_id="111.111", + client_secret="xxx", + scopes=["chat:write", "commands"], ), ) handler = SlackRequestHandler(app) diff --git a/tests/adapter_tests/test_cherrypy.py b/tests/adapter_tests/test_cherrypy.py index fec885343..f21845911 100644 --- a/tests/adapter_tests/test_cherrypy.py +++ b/tests/adapter_tests/test_cherrypy.py @@ -29,8 +29,14 @@ def setup_server(cls): signing_secret = "secret" valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) - app = App(client=web_client, signing_secret=signing_secret,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) + app = App( + client=web_client, + signing_secret=signing_secret, + ) def event_handler(): pass @@ -63,7 +69,8 @@ def teardown_class(cls): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): diff --git a/tests/adapter_tests/test_cherrypy_oauth.py b/tests/adapter_tests/test_cherrypy_oauth.py index ce8524bc8..80053331f 100644 --- a/tests/adapter_tests/test_cherrypy_oauth.py +++ b/tests/adapter_tests/test_cherrypy_oauth.py @@ -21,7 +21,10 @@ def setup_server(cls): signing_secret = "secret" valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) app = App( client=web_client, signing_secret=signing_secret, diff --git a/tests/adapter_tests/test_django.py b/tests/adapter_tests/test_django.py index 21836fc50..d1510594f 100644 --- a/tests/adapter_tests/test_django.py +++ b/tests/adapter_tests/test_django.py @@ -23,7 +23,10 @@ class TestDjango(TestCase): valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) os.environ["DJANGO_SETTINGS_MODULE"] = "tests.adapter_tests.test_django_settings" rf = RequestFactory() @@ -38,7 +41,8 @@ def tearDown(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -48,7 +52,10 @@ def build_headers(self, timestamp: str, body: str): } def test_events(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) def event_handler(): pass @@ -87,7 +94,10 @@ def event_handler(): assert self.mock_received_requests["/auth.test"] == 1 def test_shortcuts(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) def shortcut_handler(ack): ack() @@ -123,7 +133,10 @@ def shortcut_handler(ack): assert self.mock_received_requests["/auth.test"] == 1 def test_commands(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) def command_handler(ack): ack() diff --git a/tests/adapter_tests/test_django_settings.py b/tests/adapter_tests/test_django_settings.py index 7e5f57df3..8811343fe 100644 --- a/tests/adapter_tests/test_django_settings.py +++ b/tests/adapter_tests/test_django_settings.py @@ -1,4 +1,7 @@ SECRET_KEY = "XXX" DATABASES = { - "default": {"ENGINE": "django.db.backends.sqlite3", "NAME": "logs/db.sqlite3",} + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": "logs/db.sqlite3", + } } diff --git a/tests/adapter_tests/test_falcon.py b/tests/adapter_tests/test_falcon.py index e18374473..263a67275 100644 --- a/tests/adapter_tests/test_falcon.py +++ b/tests/adapter_tests/test_falcon.py @@ -22,7 +22,10 @@ class TestFalcon: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) def setup_method(self): self.old_os_env = remove_os_env_temporarily() @@ -34,7 +37,8 @@ def teardown_method(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -50,7 +54,10 @@ def build_headers(self, timestamp: str, body: str): } def test_events(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) def event_handler(): pass @@ -85,13 +92,18 @@ def event_handler(): client = testing.TestClient(api) response = client.simulate_post( - "/slack/events", body=body, headers=self.build_headers(timestamp, body), + "/slack/events", + body=body, + headers=self.build_headers(timestamp, body), ) assert response.status_code == 200 assert self.mock_received_requests["/auth.test"] == 1 def test_shortcuts(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) def shortcut_handler(ack): ack() @@ -121,13 +133,18 @@ def shortcut_handler(ack): client = testing.TestClient(api) response = client.simulate_post( - "/slack/events", body=body, headers=self.build_headers(timestamp, body), + "/slack/events", + body=body, + headers=self.build_headers(timestamp, body), ) assert response.status_code == 200 assert self.mock_received_requests["/auth.test"] == 1 def test_commands(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) def command_handler(ack): ack() @@ -157,7 +174,9 @@ def command_handler(ack): client = testing.TestClient(api) response = client.simulate_post( - "/slack/events", body=body, headers=self.build_headers(timestamp, body), + "/slack/events", + body=body, + headers=self.build_headers(timestamp, body), ) assert response.status_code == 200 assert self.mock_received_requests["/auth.test"] == 1 diff --git a/tests/adapter_tests/test_fastapi.py b/tests/adapter_tests/test_fastapi.py index 2de6ef069..3e94542d0 100644 --- a/tests/adapter_tests/test_fastapi.py +++ b/tests/adapter_tests/test_fastapi.py @@ -23,7 +23,10 @@ class TestFastAPI: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) def setup_method(self): self.old_os_env = remove_os_env_temporarily() @@ -35,7 +38,8 @@ def teardown_method(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -51,7 +55,10 @@ def build_headers(self, timestamp: str, body: str): } def test_events(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) def event_handler(): pass @@ -89,13 +96,18 @@ async def endpoint(req: Request): client = TestClient(api) response = client.post( - "/slack/events", data=body, headers=self.build_headers(timestamp, body), + "/slack/events", + data=body, + headers=self.build_headers(timestamp, body), ) assert response.status_code == 200 assert self.mock_received_requests["/auth.test"] == 1 def test_shortcuts(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) def shortcut_handler(ack): ack() @@ -128,13 +140,18 @@ async def endpoint(req: Request): client = TestClient(api) response = client.post( - "/slack/events", data=body, headers=self.build_headers(timestamp, body), + "/slack/events", + data=body, + headers=self.build_headers(timestamp, body), ) assert response.status_code == 200 assert self.mock_received_requests["/auth.test"] == 1 def test_commands(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) def command_handler(ack): ack() @@ -167,7 +184,9 @@ async def endpoint(req: Request): client = TestClient(api) response = client.post( - "/slack/events", data=body, headers=self.build_headers(timestamp, body), + "/slack/events", + data=body, + headers=self.build_headers(timestamp, body), ) assert response.status_code == 200 assert self.mock_received_requests["/auth.test"] == 1 diff --git a/tests/adapter_tests/test_flask.py b/tests/adapter_tests/test_flask.py index 30d58fc35..c6f320f6d 100644 --- a/tests/adapter_tests/test_flask.py +++ b/tests/adapter_tests/test_flask.py @@ -21,7 +21,10 @@ class TestFlask: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) def setup_method(self): self.old_os_env = remove_os_env_temporarily() @@ -33,7 +36,8 @@ def teardown_method(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -49,7 +53,10 @@ def build_headers(self, timestamp: str, body: str): } def test_events(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) def event_handler(): pass @@ -86,13 +93,18 @@ def endpoint(): with flask_app.test_client() as client: rv = client.post( - "/slack/events", data=body, headers=self.build_headers(timestamp, body), + "/slack/events", + data=body, + headers=self.build_headers(timestamp, body), ) assert rv.status_code == 200 assert self.mock_received_requests["/auth.test"] == 1 def test_shortcuts(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) def shortcut_handler(ack): ack() @@ -124,13 +136,18 @@ def endpoint(): with flask_app.test_client() as client: rv = client.post( - "/slack/events", data=body, headers=self.build_headers(timestamp, body), + "/slack/events", + data=body, + headers=self.build_headers(timestamp, body), ) assert rv.status_code == 200 assert self.mock_received_requests["/auth.test"] == 1 def test_commands(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) def command_handler(ack): ack() @@ -162,7 +179,9 @@ def endpoint(): with flask_app.test_client() as client: rv = client.post( - "/slack/events", data=body, headers=self.build_headers(timestamp, body), + "/slack/events", + data=body, + headers=self.build_headers(timestamp, body), ) assert rv.status_code == 200 assert self.mock_received_requests["/auth.test"] == 1 diff --git a/tests/adapter_tests/test_lambda_s3_oauth_flow.py b/tests/adapter_tests/test_lambda_s3_oauth_flow.py index 4e3644b64..0756bc06f 100644 --- a/tests/adapter_tests/test_lambda_s3_oauth_flow.py +++ b/tests/adapter_tests/test_lambda_s3_oauth_flow.py @@ -16,7 +16,9 @@ def teardown_method(self): def test_instantiation(self): oauth_flow = LambdaS3OAuthFlow( settings=OAuthSettings( - client_id="111.222", client_secret="xxx", scopes=["chat:write"], + client_id="111.222", + client_secret="xxx", + scopes=["chat:write"], ), installation_bucket_name="dummy-installation", oauth_state_bucket_name="dummy-state", diff --git a/tests/adapter_tests/test_pyramid.py b/tests/adapter_tests/test_pyramid.py index 5c5d78cd8..bc88b37d0 100644 --- a/tests/adapter_tests/test_pyramid.py +++ b/tests/adapter_tests/test_pyramid.py @@ -24,7 +24,10 @@ class TestPyramid(TestCase): valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) def setUp(self): self.config = testing.setUp() @@ -38,7 +41,8 @@ def tearDown(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -54,7 +58,10 @@ def build_headers(self, timestamp: str, body: str): } def test_events(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) def event_handler(): pass @@ -93,7 +100,10 @@ def event_handler(): assert self.mock_received_requests["/auth.test"] == 1 def test_shortcuts(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) def shortcut_handler(ack): ack() @@ -127,7 +137,10 @@ def shortcut_handler(ack): assert self.mock_received_requests["/auth.test"] == 1 def test_commands(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) def command_handler(ack): ack() diff --git a/tests/adapter_tests/test_starlette.py b/tests/adapter_tests/test_starlette.py index 9ab513d26..4dc4059f9 100644 --- a/tests/adapter_tests/test_starlette.py +++ b/tests/adapter_tests/test_starlette.py @@ -24,7 +24,10 @@ class TestStarlette: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) def setup_method(self): self.old_os_env = remove_os_env_temporarily() @@ -36,7 +39,8 @@ def teardown_method(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -52,7 +56,10 @@ def build_headers(self, timestamp: str, body: str): } def test_events(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) def event_handler(): pass @@ -92,13 +99,18 @@ async def endpoint(req: Request): ) client = TestClient(api) response = client.post( - "/slack/events", data=body, headers=self.build_headers(timestamp, body), + "/slack/events", + data=body, + headers=self.build_headers(timestamp, body), ) assert response.status_code == 200 assert self.mock_received_requests["/auth.test"] == 1 def test_shortcuts(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) def shortcut_handler(ack): ack() @@ -133,13 +145,18 @@ async def endpoint(req: Request): ) client = TestClient(api) response = client.post( - "/slack/events", data=body, headers=self.build_headers(timestamp, body), + "/slack/events", + data=body, + headers=self.build_headers(timestamp, body), ) assert response.status_code == 200 assert self.mock_received_requests["/auth.test"] == 1 def test_commands(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) def command_handler(ack): ack() @@ -174,7 +191,9 @@ async def endpoint(req: Request): ) client = TestClient(api) response = client.post( - "/slack/events", data=body, headers=self.build_headers(timestamp, body), + "/slack/events", + data=body, + headers=self.build_headers(timestamp, body), ) assert response.status_code == 200 assert self.mock_received_requests["/auth.test"] == 1 diff --git a/tests/adapter_tests/test_tornado.py b/tests/adapter_tests/test_tornado.py index 468690fb6..87c4ccc09 100644 --- a/tests/adapter_tests/test_tornado.py +++ b/tests/adapter_tests/test_tornado.py @@ -41,8 +41,14 @@ def setUp(self): self.old_os_env = remove_os_env_temporarily() setup_mock_web_api_server(self) - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) - self.app = App(client=web_client, signing_secret=signing_secret,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) + self.app = App( + client=web_client, + signing_secret=signing_secret, + ) self.app.event("app_mention")(event_handler) self.app.shortcut("test-shortcut")(shortcut_handler) self.app.command("/hello-world")(command_handler) @@ -59,7 +65,8 @@ def get_app(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): diff --git a/tests/adapter_tests/test_tornado_oauth.py b/tests/adapter_tests/test_tornado_oauth.py index c42468f2a..ae98a6ac6 100644 --- a/tests/adapter_tests/test_tornado_oauth.py +++ b/tests/adapter_tests/test_tornado_oauth.py @@ -13,7 +13,9 @@ app = App( signing_secret=signing_secret, oauth_settings=OAuthSettings( - client_id="111.111", client_secret="xxx", scopes=["chat:write", "commands"], + client_id="111.111", + client_secret="xxx", + scopes=["chat:write", "commands"], ), ) diff --git a/tests/adapter_tests_async/test_async_fastapi.py b/tests/adapter_tests_async/test_async_fastapi.py index 41b8a332e..f9c2c842b 100644 --- a/tests/adapter_tests_async/test_async_fastapi.py +++ b/tests/adapter_tests_async/test_async_fastapi.py @@ -23,7 +23,10 @@ class TestFastAPI: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = AsyncWebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = AsyncWebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) def setup_method(self): self.old_os_env = remove_os_env_temporarily() @@ -35,7 +38,8 @@ def teardown_method(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -51,7 +55,10 @@ def build_headers(self, timestamp: str, body: str): } def test_events(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) async def event_handler(): pass @@ -89,13 +96,18 @@ async def endpoint(req: Request): client = TestClient(api) response = client.post( - "/slack/events", data=body, headers=self.build_headers(timestamp, body), + "/slack/events", + data=body, + headers=self.build_headers(timestamp, body), ) assert response.status_code == 200 assert self.mock_received_requests["/auth.test"] == 1 def test_shortcuts(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) async def shortcut_handler(ack): await ack() @@ -128,13 +140,18 @@ async def endpoint(req: Request): client = TestClient(api) response = client.post( - "/slack/events", data=body, headers=self.build_headers(timestamp, body), + "/slack/events", + data=body, + headers=self.build_headers(timestamp, body), ) assert response.status_code == 200 assert self.mock_received_requests["/auth.test"] == 1 def test_commands(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) async def command_handler(ack): await ack() @@ -167,7 +184,9 @@ async def endpoint(req: Request): client = TestClient(api) response = client.post( - "/slack/events", data=body, headers=self.build_headers(timestamp, body), + "/slack/events", + data=body, + headers=self.build_headers(timestamp, body), ) assert response.status_code == 200 assert self.mock_received_requests["/auth.test"] == 1 diff --git a/tests/adapter_tests_async/test_async_sanic.py b/tests/adapter_tests_async/test_async_sanic.py index 587f858b6..38d91d95a 100644 --- a/tests/adapter_tests_async/test_async_sanic.py +++ b/tests/adapter_tests_async/test_async_sanic.py @@ -24,7 +24,10 @@ class TestSanic: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = AsyncWebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = AsyncWebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) @pytest.fixture def event_loop(self): @@ -40,7 +43,8 @@ def event_loop(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -57,7 +61,10 @@ def build_headers(self, timestamp: str, body: str): @pytest.mark.asyncio async def test_events(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) async def event_handler(): pass @@ -94,14 +101,19 @@ async def endpoint(req: Request): return await app_handler.handle(req) _, response = await api.asgi_client.post( - url="/slack/events", data=body, headers=self.build_headers(timestamp, body), + url="/slack/events", + data=body, + headers=self.build_headers(timestamp, body), ) assert response.status_code == 200 assert self.mock_received_requests["/auth.test"] == 1 @pytest.mark.asyncio async def test_shortcuts(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) async def shortcut_handler(ack): await ack() @@ -133,14 +145,19 @@ async def endpoint(req: Request): return await app_handler.handle(req) _, response = await api.asgi_client.post( - url="/slack/events", data=body, headers=self.build_headers(timestamp, body), + url="/slack/events", + data=body, + headers=self.build_headers(timestamp, body), ) assert response.status_code == 200 assert self.mock_received_requests["/auth.test"] == 1 @pytest.mark.asyncio async def test_commands(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) async def command_handler(ack): await ack() @@ -172,7 +189,9 @@ async def endpoint(req: Request): return await app_handler.handle(req) _, response = await api.asgi_client.post( - url="/slack/events", data=body, headers=self.build_headers(timestamp, body), + url="/slack/events", + data=body, + headers=self.build_headers(timestamp, body), ) assert response.status_code == 200 assert self.mock_received_requests["/auth.test"] == 1 diff --git a/tests/adapter_tests_async/test_async_starlette.py b/tests/adapter_tests_async/test_async_starlette.py index 17c81715f..3faba8b12 100644 --- a/tests/adapter_tests_async/test_async_starlette.py +++ b/tests/adapter_tests_async/test_async_starlette.py @@ -24,7 +24,10 @@ class TestAsyncStarlette: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = AsyncWebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = AsyncWebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) def setup_method(self): self.old_os_env = remove_os_env_temporarily() @@ -36,7 +39,8 @@ def teardown_method(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -52,7 +56,10 @@ def build_headers(self, timestamp: str, body: str): } def test_events(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) async def event_handler(): pass @@ -92,13 +99,18 @@ async def endpoint(req: Request): client = TestClient(api) response = client.post( - "/slack/events", data=body, headers=self.build_headers(timestamp, body), + "/slack/events", + data=body, + headers=self.build_headers(timestamp, body), ) assert response.status_code == 200 assert self.mock_received_requests["/auth.test"] == 1 def test_shortcuts(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) async def shortcut_handler(ack): await ack() @@ -133,13 +145,18 @@ async def endpoint(req: Request): client = TestClient(api) response = client.post( - "/slack/events", data=body, headers=self.build_headers(timestamp, body), + "/slack/events", + data=body, + headers=self.build_headers(timestamp, body), ) assert response.status_code == 200 assert self.mock_received_requests["/auth.test"] == 1 def test_commands(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) async def command_handler(ack): await ack() @@ -174,7 +191,9 @@ async def endpoint(req: Request): client = TestClient(api) response = client.post( - "/slack/events", data=body, headers=self.build_headers(timestamp, body), + "/slack/events", + data=body, + headers=self.build_headers(timestamp, body), ) assert response.status_code == 200 assert self.mock_received_requests["/auth.test"] == 1 diff --git a/tests/scenario_tests/test_app.py b/tests/scenario_tests/test_app.py index af2e98c34..5d91dd577 100644 --- a/tests/scenario_tests/test_app.py +++ b/tests/scenario_tests/test_app.py @@ -19,7 +19,10 @@ class TestApp: signing_secret = "secret" valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) def setup_method(self): self.old_os_env = remove_os_env_temporarily() @@ -152,7 +155,9 @@ def test_installation_store_conflicts(self): app = App( signing_secret="valid", oauth_settings=OAuthSettings( - client_id="111.222", client_secret="valid", installation_store=store1, + client_id="111.222", + client_secret="valid", + installation_store=store1, ), installation_store=store2, ) @@ -174,7 +179,10 @@ def test_installation_store_conflicts(self): app = App( signing_secret="valid", oauth_flow=OAuthFlow( - settings=OAuthSettings(client_id="111.222", client_secret="valid",) + settings=OAuthSettings( + client_id="111.222", + client_secret="valid", + ) ), installation_store=store1, ) diff --git a/tests/scenario_tests/test_app_bot_only.py b/tests/scenario_tests/test_app_bot_only.py index c6cfca323..53da026f9 100644 --- a/tests/scenario_tests/test_app_bot_only.py +++ b/tests/scenario_tests/test_app_bot_only.py @@ -88,7 +88,10 @@ class TestApp: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) def setup_method(self): self.old_os_env = remove_os_env_temporarily() @@ -100,7 +103,8 @@ def teardown_method(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): diff --git a/tests/scenario_tests/test_attachment_actions.py b/tests/scenario_tests/test_attachment_actions.py index 3596dbcbd..c520a11ad 100644 --- a/tests/scenario_tests/test_attachment_actions.py +++ b/tests/scenario_tests/test_attachment_actions.py @@ -19,7 +19,10 @@ class TestAttachmentActions: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) def setup_method(self): self.old_os_env = remove_os_env_temporarily() @@ -31,7 +34,8 @@ def teardown_method(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -52,7 +56,10 @@ def test_mock_server_is_running(self): assert resp != None def test_success_without_type(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.action("pick_channel_for_fun")(simple_listener) request = self.build_valid_request() @@ -61,9 +68,15 @@ def test_success_without_type(self): assert self.mock_received_requests["/auth.test"] == 1 def test_success(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.action( - {"callback_id": "pick_channel_for_fun", "type": "interactive_message",} + { + "callback_id": "pick_channel_for_fun", + "type": "interactive_message", + } )(simple_listener) request = self.build_valid_request() @@ -72,7 +85,10 @@ def test_success(self): assert self.mock_received_requests["/auth.test"] == 1 def test_success_2(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.attachment_action("pick_channel_for_fun")(simple_listener) request = self.build_valid_request() @@ -87,7 +103,10 @@ def test_process_before_response(self): process_before_response=True, ) app.action( - {"callback_id": "pick_channel_for_fun", "type": "interactive_message",} + { + "callback_id": "pick_channel_for_fun", + "type": "interactive_message", + } )(simple_listener) request = self.build_valid_request() @@ -96,7 +115,10 @@ def test_process_before_response(self): assert self.mock_received_requests["/auth.test"] == 1 def test_failure_without_type(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request() response = app.dispatch(request) assert response.status == 404 @@ -108,21 +130,30 @@ def test_failure_without_type(self): assert self.mock_received_requests["/auth.test"] == 1 def test_failure(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request() response = app.dispatch(request) assert response.status == 404 assert self.mock_received_requests["/auth.test"] == 1 - app.action({"callback_id": "unknown", "type": "interactive_message",})( - simple_listener - ) + app.action( + { + "callback_id": "unknown", + "type": "interactive_message", + } + )(simple_listener) response = app.dispatch(request) assert response.status == 404 assert self.mock_received_requests["/auth.test"] == 1 def test_failure_2(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request() response = app.dispatch(request) assert response.status == 404 diff --git a/tests/scenario_tests/test_authorize.py b/tests/scenario_tests/test_authorize.py index 86bebef7d..6bb4345e8 100644 --- a/tests/scenario_tests/test_authorize.py +++ b/tests/scenario_tests/test_authorize.py @@ -24,7 +24,8 @@ def authorize(enterprise_id, team_id, user_id, client: WebClient): assert user_id == "W99999" auth_test = client.auth_test(token=valid_token) return AuthorizeResult.from_auth_test_response( - auth_test_response=auth_test, bot_token=valid_token, + auth_test_response=auth_test, + bot_token=valid_token, ) @@ -34,7 +35,8 @@ def user_authorize(enterprise_id, team_id, user_id, client: WebClient): assert user_id == "W99999" auth_test = client.auth_test(token=valid_user_token) return AuthorizeResult.from_auth_test_response( - auth_test_response=auth_test, user_token=valid_user_token, + auth_test_response=auth_test, + user_token=valid_user_token, ) @@ -49,7 +51,10 @@ class TestAuthorize: signing_secret = "secret" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) def setup_method(self): self.old_os_env = remove_os_env_temporarily() @@ -61,7 +66,8 @@ def teardown_method(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): diff --git a/tests/scenario_tests/test_block_actions.py b/tests/scenario_tests/test_block_actions.py index bfe851c6f..6280bf6ed 100644 --- a/tests/scenario_tests/test_block_actions.py +++ b/tests/scenario_tests/test_block_actions.py @@ -19,7 +19,10 @@ class TestBlockActions: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) def setup_method(self): self.old_os_env = remove_os_env_temporarily() @@ -31,7 +34,8 @@ def teardown_method(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -52,7 +56,10 @@ def test_mock_server_is_running(self): assert resp != None def test_success(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.action("a")(simple_listener) request = self.build_valid_request() @@ -61,7 +68,10 @@ def test_success(self): assert self.mock_received_requests["/auth.test"] == 1 def test_success_2(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.block_action("a")(simple_listener) request = self.build_valid_request() @@ -110,7 +120,10 @@ def test_default_type_and_unmatched_block_id(self): assert self.mock_received_requests["/auth.test"] == 1 def test_failure(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request() response = app.dispatch(request) assert response.status == 404 @@ -122,7 +135,10 @@ def test_failure(self): assert self.mock_received_requests["/auth.test"] == 1 def test_failure_2(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request() response = app.dispatch(request) assert response.status == 404 diff --git a/tests/scenario_tests/test_block_suggestion.py b/tests/scenario_tests/test_block_suggestion.py index 341039377..67c5428a8 100644 --- a/tests/scenario_tests/test_block_suggestion.py +++ b/tests/scenario_tests/test_block_suggestion.py @@ -20,7 +20,10 @@ class TestBlockSuggestion: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) def setup_method(self): self.old_os_env = remove_os_env_temporarily() @@ -32,7 +35,8 @@ def teardown_method(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -59,7 +63,10 @@ def test_mock_server_is_running(self): assert resp != None def test_success(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.options("es_a")(show_options) request = self.build_valid_request() @@ -70,7 +77,10 @@ def test_success(self): assert self.mock_received_requests["/auth.test"] == 1 def test_success_2(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.block_suggestion("es_a")(show_options) request = self.build_valid_request() @@ -81,7 +91,10 @@ def test_success_2(self): assert self.mock_received_requests["/auth.test"] == 1 def test_success_multi(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.options("mes_a")(show_multi_options) request = self.build_valid_multi_request() @@ -122,7 +135,10 @@ def test_process_before_response_multi(self): assert self.mock_received_requests["/auth.test"] == 1 def test_failure(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request() response = app.dispatch(request) assert response.status == 404 @@ -134,7 +150,10 @@ def test_failure(self): assert self.mock_received_requests["/auth.test"] == 1 def test_failure_2(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request() response = app.dispatch(request) assert response.status == 404 @@ -146,7 +165,10 @@ def test_failure_2(self): assert self.mock_received_requests["/auth.test"] == 1 def test_failure_multi(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_multi_request() response = app.dispatch(request) assert response.status == 404 diff --git a/tests/scenario_tests/test_dialogs.py b/tests/scenario_tests/test_dialogs.py index 1d6b20c8f..671ca723e 100644 --- a/tests/scenario_tests/test_dialogs.py +++ b/tests/scenario_tests/test_dialogs.py @@ -19,7 +19,10 @@ class TestAttachmentActions: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) def setup_method(self): self.old_os_env = remove_os_env_temporarily() @@ -31,7 +34,8 @@ def teardown_method(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -50,7 +54,10 @@ def test_mock_server_is_running(self): assert resp != None def test_success_without_type(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.options("dialog-callback-id")(handle_suggestion) app.action("dialog-callback-id")(handle_submission_cancellation) @@ -74,7 +81,10 @@ def test_success_without_type(self): assert self.mock_received_requests["/auth.test"] == 1 def test_success(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.options({"type": "dialog_suggestion", "callback_id": "dialog-callback-id"})( handle_suggestion ) @@ -105,7 +115,10 @@ def test_success(self): assert self.mock_received_requests["/auth.test"] == 1 def test_success_2(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.dialog_suggestion("dialog-callback-id")(handle_suggestion) app.dialog_submission("dialog-callback-id")(handle_submission) app.dialog_cancellation("dialog-callback-id")(handle_cancellation) @@ -194,7 +207,10 @@ def test_process_before_response_2(self): assert self.mock_received_requests["/auth.test"] == 1 def test_suggestion_failure_without_type(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request(suggestion_raw_body) response = app.dispatch(request) assert response.status == 404 @@ -206,7 +222,10 @@ def test_suggestion_failure_without_type(self): assert self.mock_received_requests["/auth.test"] == 1 def test_suggestion_failure(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request(suggestion_raw_body) response = app.dispatch(request) assert response.status == 404 @@ -218,7 +237,10 @@ def test_suggestion_failure(self): assert self.mock_received_requests["/auth.test"] == 1 def test_suggestion_failure_2(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request(suggestion_raw_body) response = app.dispatch(request) assert response.status == 404 @@ -232,7 +254,10 @@ def test_suggestion_failure_2(self): assert self.mock_received_requests["/auth.test"] == 1 def test_submission_failure_without_type(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request(suggestion_raw_body) response = app.dispatch(request) assert response.status == 404 @@ -244,7 +269,10 @@ def test_submission_failure_without_type(self): assert self.mock_received_requests["/auth.test"] == 1 def test_submission_failure(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request(suggestion_raw_body) response = app.dispatch(request) assert response.status == 404 @@ -256,7 +284,10 @@ def test_submission_failure(self): assert self.mock_received_requests["/auth.test"] == 1 def test_submission_failure_2(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request(suggestion_raw_body) response = app.dispatch(request) assert response.status == 404 @@ -270,7 +301,10 @@ def test_submission_failure_2(self): assert self.mock_received_requests["/auth.test"] == 1 def test_cancellation_failure_without_type(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request(suggestion_raw_body) response = app.dispatch(request) assert response.status == 404 @@ -282,7 +316,10 @@ def test_cancellation_failure_without_type(self): assert self.mock_received_requests["/auth.test"] == 1 def test_cancellation_failure(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request(suggestion_raw_body) response = app.dispatch(request) assert response.status == 404 @@ -294,7 +331,10 @@ def test_cancellation_failure(self): assert self.mock_received_requests["/auth.test"] == 1 def test_cancellation_failure_2(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request(suggestion_raw_body) response = app.dispatch(request) assert response.status == 404 @@ -381,7 +421,10 @@ def handle_submission(ack): "value": "UXD-342", }, {"label": "[FE-459] Remove the marquee tag", "value": "FE-459"}, - {"label": "[FE-238] Too many shades of gray in master CSS", "value": "FE-238",}, + { + "label": "[FE-238] Too many shades of gray in master CSS", + "value": "FE-238", + }, ] } diff --git a/tests/scenario_tests/test_error_handler.py b/tests/scenario_tests/test_error_handler.py index 131454633..7ebcc224d 100644 --- a/tests/scenario_tests/test_error_handler.py +++ b/tests/scenario_tests/test_error_handler.py @@ -19,7 +19,10 @@ class TestErrorHandler: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) def setup_method(self): self.old_os_env = remove_os_env_temporarily() @@ -35,7 +38,8 @@ def teardown_method(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -48,11 +52,15 @@ def build_headers(self, timestamp: str, body: str): def build_valid_request(self) -> BoltRequest: body = { "type": "block_actions", - "user": {"id": "W111",}, + "user": { + "id": "W111", + }, "api_app_id": "A111", "token": "verification_token", "trigger_id": "111.222.valid", - "team": {"id": "T111",}, + "team": { + "id": "T111", + }, "channel": {"id": "C111", "name": "test-channel"}, "response_url": "https://hooks.slack.com/actions/T111/111/random-value", "actions": [ @@ -80,7 +88,10 @@ def test_default(self): def failing_listener(): raise Exception("Something wrong!") - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.action("a")(failing_listener) request = self.build_valid_request() @@ -95,7 +106,10 @@ def error_handler(logger, payload, response): def failing_listener(): raise Exception("Something wrong!") - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.error(error_handler) app.action("a")(failing_listener) diff --git a/tests/scenario_tests/test_events.py b/tests/scenario_tests/test_events.py index 4a2b02dc8..12ec82742 100644 --- a/tests/scenario_tests/test_events.py +++ b/tests/scenario_tests/test_events.py @@ -17,7 +17,10 @@ class TestEvents: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) def setup_method(self): self.old_os_env = remove_os_env_temporarily() @@ -29,7 +32,8 @@ def teardown_method(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): diff --git a/tests/scenario_tests/test_events_org_apps.py b/tests/scenario_tests/test_events_org_apps.py index 01dbe4be0..c9c2e737b 100644 --- a/tests/scenario_tests/test_events_org_apps.py +++ b/tests/scenario_tests/test_events_org_apps.py @@ -47,7 +47,8 @@ class TestEventsOrgApps: mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) web_client: WebClient = WebClient( - token=None, base_url=mock_api_server_base_url, + token=None, + base_url=mock_api_server_base_url, ) def setup_method(self): @@ -60,7 +61,8 @@ def teardown_method(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): diff --git a/tests/scenario_tests/test_events_shared_channels.py b/tests/scenario_tests/test_events_shared_channels.py index 702b515f3..9829d91bc 100644 --- a/tests/scenario_tests/test_events_shared_channels.py +++ b/tests/scenario_tests/test_events_shared_channels.py @@ -20,7 +20,8 @@ def authorize(enterprise_id, team_id, client: WebClient): assert team_id == "T_INSTALLED" auth_test = client.auth_test(token=valid_token) return AuthorizeResult.from_auth_test_response( - auth_test_response=auth_test, bot_token=valid_token, + auth_test_response=auth_test, + bot_token=valid_token, ) @@ -29,7 +30,8 @@ class TestEventsSharedChannels: mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) web_client: WebClient = WebClient( - token=None, base_url=mock_api_server_base_url, + token=None, + base_url=mock_api_server_base_url, ) def setup_method(self): @@ -42,7 +44,8 @@ def teardown_method(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): diff --git a/tests/scenario_tests/test_events_socket_mode.py b/tests/scenario_tests/test_events_socket_mode.py index 5a02f9624..2bb8709e4 100644 --- a/tests/scenario_tests/test_events_socket_mode.py +++ b/tests/scenario_tests/test_events_socket_mode.py @@ -15,7 +15,10 @@ class TestEventsSocketMode: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) def setup_method(self): self.old_os_env = remove_os_env_temporarily() diff --git a/tests/scenario_tests/test_lazy.py b/tests/scenario_tests/test_lazy.py index 0a81b3488..8a633f8cc 100644 --- a/tests/scenario_tests/test_lazy.py +++ b/tests/scenario_tests/test_lazy.py @@ -19,7 +19,10 @@ class TestErrorHandler: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) def setup_method(self): self.old_os_env = remove_os_env_temporarily() @@ -35,7 +38,8 @@ def teardown_method(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -48,11 +52,15 @@ def build_headers(self, timestamp: str, body: str): def build_valid_request(self) -> BoltRequest: body = { "type": "block_actions", - "user": {"id": "W111",}, + "user": { + "id": "W111", + }, "api_app_id": "A111", "token": "verification_token", "trigger_id": "111.222.valid", - "team": {"id": "T111",}, + "team": { + "id": "T111", + }, "channel": {"id": "C111", "name": "test-channel"}, "response_url": "https://hooks.slack.com/actions/T111/111/random-value", "actions": [ @@ -88,9 +96,13 @@ def async2(say): time.sleep(0.5) say(text="lazy function 2") - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.action("a")( - ack=just_ack, lazy=[async1, async2], + ack=just_ack, + lazy=[async1, async2], ) request = self.build_valid_request() diff --git a/tests/scenario_tests/test_message.py b/tests/scenario_tests/test_message.py index 1acfe56b7..d99edffc1 100644 --- a/tests/scenario_tests/test_message.py +++ b/tests/scenario_tests/test_message.py @@ -19,7 +19,10 @@ class TestMessage: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) def setup_method(self): self.old_os_env = remove_os_env_temporarily() @@ -31,7 +34,8 @@ def teardown_method(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -50,7 +54,10 @@ def build_request2(self) -> BoltRequest: return BoltRequest(body=body, headers=self.build_headers(timestamp, body)) def test_string_keyword(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.message("Hello")(whats_up) request = self.build_request() @@ -61,7 +68,10 @@ def test_string_keyword(self): assert self.mock_received_requests["/chat.postMessage"] == 1 def test_string_keyword_capturing(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.message("We've received ([0-9]+) messages from (.+)!")(verify_matches) request = self.build_request2() @@ -72,7 +82,10 @@ def test_string_keyword_capturing(self): assert self.mock_received_requests["/chat.postMessage"] == 1 def test_string_keyword_capturing2(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.message(re.compile("We've received ([0-9]+) messages from (.+)!"))( verify_matches ) @@ -85,7 +98,10 @@ def test_string_keyword_capturing2(self): assert self.mock_received_requests["/chat.postMessage"] == 1 def test_string_keyword_unmatched(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.message("HELLO")(whats_up) request = self.build_request() @@ -94,7 +110,10 @@ def test_string_keyword_unmatched(self): assert self.mock_received_requests["/auth.test"] == 1 def test_regexp_keyword(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.message(re.compile("He.lo"))(whats_up) request = self.build_request() @@ -105,7 +124,10 @@ def test_regexp_keyword(self): assert self.mock_received_requests["/chat.postMessage"] == 1 def test_regexp_keyword_unmatched(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.message(re.compile("HELLO"))(whats_up) request = self.build_request() diff --git a/tests/scenario_tests/test_middleware.py b/tests/scenario_tests/test_middleware.py index 517c1b1ce..569dc6261 100644 --- a/tests/scenario_tests/test_middleware.py +++ b/tests/scenario_tests/test_middleware.py @@ -18,7 +18,10 @@ class TestMiddleware: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) def setup_method(self): self.old_os_env = remove_os_env_temporarily() @@ -50,7 +53,8 @@ def build_request(self) -> BoltRequest: "content-type": ["application/json"], "x-slack-signature": [ self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) ], "x-slack-request-timestamp": [timestamp], @@ -58,7 +62,10 @@ def build_request(self) -> BoltRequest: ) def test_no_next_call(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.use(no_next) app.shortcut("test-shortcut")(just_ack) @@ -67,7 +74,10 @@ def test_no_next_call(self): assert self.mock_received_requests["/auth.test"] == 1 def test_next_call(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.use(just_next) app.shortcut("test-shortcut")(just_ack) diff --git a/tests/scenario_tests/test_shortcut.py b/tests/scenario_tests/test_shortcut.py index b646d77a3..42143942a 100644 --- a/tests/scenario_tests/test_shortcut.py +++ b/tests/scenario_tests/test_shortcut.py @@ -19,7 +19,10 @@ class TestShortcut: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) def setup_method(self): self.old_os_env = remove_os_env_temporarily() @@ -31,7 +34,8 @@ def teardown_method(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -51,7 +55,10 @@ def test_mock_server_is_running(self): # NOTE: This is a compatible behavior with Bolt for JS def test_success_both_global_and_message(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.shortcut("test-shortcut")(simple_listener) request = self.build_valid_request(global_shortcut_raw_body) @@ -65,7 +72,10 @@ def test_success_both_global_and_message(self): assert self.mock_received_requests["/auth.test"] == 1 def test_success_global(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.shortcut("test-shortcut")(simple_listener) request = self.build_valid_request(global_shortcut_raw_body) @@ -74,7 +84,10 @@ def test_success_global(self): assert self.mock_received_requests["/auth.test"] == 1 def test_success_global_2(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.global_shortcut("test-shortcut")(simple_listener) request = self.build_valid_request(global_shortcut_raw_body) @@ -88,7 +101,10 @@ def test_success_global_2(self): assert self.mock_received_requests["/auth.test"] == 1 def test_success_message(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.shortcut({"type": "message_action", "callback_id": "test-shortcut"})( simple_listener ) @@ -104,7 +120,10 @@ def test_success_message(self): assert self.mock_received_requests["/auth.test"] == 1 def test_success_message_2(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.message_shortcut("test-shortcut")(simple_listener) request = self.build_valid_request(message_shortcut_raw_body) @@ -131,7 +150,10 @@ def test_process_before_response_global(self): assert self.mock_received_requests["/auth.test"] == 1 def test_failure(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request(global_shortcut_raw_body) response = app.dispatch(request) assert response.status == 404 @@ -143,7 +165,10 @@ def test_failure(self): assert self.mock_received_requests["/auth.test"] == 1 def test_failure_2(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request(global_shortcut_raw_body) response = app.dispatch(request) assert response.status == 404 diff --git a/tests/scenario_tests/test_slash_command.py b/tests/scenario_tests/test_slash_command.py index acfac442b..23f07dbc0 100644 --- a/tests/scenario_tests/test_slash_command.py +++ b/tests/scenario_tests/test_slash_command.py @@ -18,7 +18,10 @@ class TestSlashCommand: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) def setup_method(self): self.old_os_env = remove_os_env_temporarily() @@ -30,7 +33,8 @@ def teardown_method(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -49,7 +53,10 @@ def test_mock_server_is_running(self): assert resp != None def test_success(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.command("/hello-world")(commander) request = self.build_valid_request() @@ -71,7 +78,10 @@ def test_process_before_response(self): assert self.mock_received_requests["/auth.test"] == 1 def test_failure(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request() response = app.dispatch(request) assert response.status == 404 diff --git a/tests/scenario_tests/test_ssl_check.py b/tests/scenario_tests/test_ssl_check.py index bb27939fd..3470321de 100644 --- a/tests/scenario_tests/test_ssl_check.py +++ b/tests/scenario_tests/test_ssl_check.py @@ -16,7 +16,10 @@ class TestSSLCheck: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) def setup_method(self): self.old_os_env = remove_os_env_temporarily() @@ -28,7 +31,8 @@ def teardown_method(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def test_mock_server_is_running(self): diff --git a/tests/scenario_tests/test_view_closed.py b/tests/scenario_tests/test_view_closed.py index 55c34ab4c..8294108f1 100644 --- a/tests/scenario_tests/test_view_closed.py +++ b/tests/scenario_tests/test_view_closed.py @@ -19,7 +19,10 @@ class TestViewClosed: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) def setup_method(self): self.old_os_env = remove_os_env_temporarily() @@ -31,7 +34,8 @@ def teardown_method(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -52,7 +56,10 @@ def test_mock_server_is_running(self): assert resp != None def test_success(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.view({"type": "view_closed", "callback_id": "view-id"})(simple_listener) request = self.build_valid_request() @@ -61,7 +68,10 @@ def test_success(self): assert self.mock_received_requests["/auth.test"] == 1 def test_success_2(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.view_closed("view-id")(simple_listener) request = self.build_valid_request() @@ -83,7 +93,10 @@ def test_process_before_response(self): assert self.mock_received_requests["/auth.test"] == 1 def test_failure(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request() response = app.dispatch(request) assert response.status == 404 @@ -95,7 +108,10 @@ def test_failure(self): assert self.mock_received_requests["/auth.test"] == 1 def test_failure(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request() response = app.dispatch(request) assert response.status == 404 @@ -107,7 +123,10 @@ def test_failure(self): assert self.mock_received_requests["/auth.test"] == 1 def test_failure_2(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request() response = app.dispatch(request) assert response.status == 404 @@ -143,7 +162,10 @@ def test_failure_2(self): { "type": "input", "block_id": "hspI", - "label": {"type": "plain_text", "text": "Label",}, + "label": { + "type": "plain_text", + "text": "Label", + }, "optional": False, "element": {"type": "plain_text_input", "action_id": "maBWU"}, } @@ -152,11 +174,20 @@ def test_failure_2(self): "callback_id": "view-id", "state": {"values": {}}, "hash": "1596530361.3wRYuk3R", - "title": {"type": "plain_text", "text": "My App",}, + "title": { + "type": "plain_text", + "text": "My App", + }, "clear_on_close": False, "notify_on_close": False, - "close": {"type": "plain_text", "text": "Cancel",}, - "submit": {"type": "plain_text", "text": "Submit",}, + "close": { + "type": "plain_text", + "text": "Cancel", + }, + "submit": { + "type": "plain_text", + "text": "Submit", + }, "previous_view_id": None, "root_view_id": "V111", "app_id": "A111", diff --git a/tests/scenario_tests/test_view_submission.py b/tests/scenario_tests/test_view_submission.py index c0ecbfa2e..ced03e181 100644 --- a/tests/scenario_tests/test_view_submission.py +++ b/tests/scenario_tests/test_view_submission.py @@ -19,7 +19,10 @@ class TestViewSubmission: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) def setup_method(self): self.old_os_env = remove_os_env_temporarily() @@ -31,7 +34,8 @@ def teardown_method(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -52,7 +56,10 @@ def test_mock_server_is_running(self): assert resp != None def test_success(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.view("view-id")(simple_listener) request = self.build_valid_request() @@ -61,7 +68,10 @@ def test_success(self): assert self.mock_received_requests["/auth.test"] == 1 def test_success_2(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.view_submission("view-id")(simple_listener) request = self.build_valid_request() @@ -83,7 +93,10 @@ def test_process_before_response(self): assert self.mock_received_requests["/auth.test"] == 1 def test_failure(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request() response = app.dispatch(request) assert response.status == 404 @@ -95,7 +108,10 @@ def test_failure(self): assert self.mock_received_requests["/auth.test"] == 1 def test_failure_2(self): - app = App(client=self.web_client, signing_secret=self.signing_secret,) + app = App( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request() response = app.dispatch(request) assert response.status == 404 @@ -132,7 +148,10 @@ def test_failure_2(self): { "type": "input", "block_id": "hspI", - "label": {"type": "plain_text", "text": "Label",}, + "label": { + "type": "plain_text", + "text": "Label", + }, "optional": False, "element": {"type": "plain_text_input", "action_id": "maBWU"}, } @@ -143,11 +162,20 @@ def test_failure_2(self): "values": {"hspI": {"maBWU": {"type": "plain_text_input", "value": "test"}}} }, "hash": "1596530361.3wRYuk3R", - "title": {"type": "plain_text", "text": "My App",}, + "title": { + "type": "plain_text", + "text": "My App", + }, "clear_on_close": False, "notify_on_close": False, - "close": {"type": "plain_text", "text": "Cancel",}, - "submit": {"type": "plain_text", "text": "Submit",}, + "close": { + "type": "plain_text", + "text": "Cancel", + }, + "submit": { + "type": "plain_text", + "text": "Submit", + }, "previous_view_id": None, "root_view_id": "V111", "app_id": "A111", diff --git a/tests/scenario_tests/test_workflow_steps.py b/tests/scenario_tests/test_workflow_steps.py index 9dacd83a3..b41d32e12 100644 --- a/tests/scenario_tests/test_workflow_steps.py +++ b/tests/scenario_tests/test_workflow_steps.py @@ -32,7 +32,8 @@ def teardown_method(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_app(self, callback_id: str): @@ -364,7 +365,10 @@ def edit(ack: Ack, step, configure: Configure): "element": { "type": "plain_text_input", "action_id": "task_name", - "placeholder": {"type": "plain_text", "text": "Write a task name",}, + "placeholder": { + "type": "plain_text", + "text": "Write a task name", + }, }, "label": {"type": "plain_text", "text": "Task name"}, }, @@ -387,7 +391,10 @@ def edit(ack: Ack, step, configure: Configure): "element": { "type": "plain_text_input", "action_id": "task_author", - "placeholder": {"type": "plain_text", "text": "Write a task name",}, + "placeholder": { + "type": "plain_text", + "text": "Write a task name", + }, }, "label": {"type": "plain_text", "text": "Task author"}, }, @@ -414,9 +421,21 @@ def save(ack: Ack, step: dict, view: dict, update: Update): }, }, outputs=[ - {"name": "taskName", "type": "text", "label": "Task Name",}, - {"name": "taskDescription", "type": "text", "label": "Task Description",}, - {"name": "taskAuthorEmail", "type": "text", "label": "Task Author Email",}, + { + "name": "taskName", + "type": "text", + "label": "Task Name", + }, + { + "name": "taskDescription", + "type": "text", + "label": "Task Description", + }, + { + "name": "taskAuthorEmail", + "type": "text", + "label": "Task Author Email", + }, ], ) ack() @@ -487,7 +506,8 @@ def save_lazy(step: dict, view: dict, update: Update): assert step is not None assert view is not None update( - inputs={}, outputs=[], + inputs={}, + outputs=[], ) diff --git a/tests/scenario_tests_async/test_app.py b/tests/scenario_tests_async/test_app.py index 6f9d0a8a8..1640087bc 100644 --- a/tests/scenario_tests_async/test_app.py +++ b/tests/scenario_tests_async/test_app.py @@ -131,7 +131,9 @@ def test_installation_store_conflicts(self): app = AsyncApp( signing_secret="valid", oauth_settings=AsyncOAuthSettings( - client_id="111.222", client_secret="valid", installation_store=store1, + client_id="111.222", + client_secret="valid", + installation_store=store1, ), installation_store=store2, ) @@ -153,7 +155,10 @@ def test_installation_store_conflicts(self): app = AsyncApp( signing_secret="valid", oauth_flow=AsyncOAuthFlow( - settings=AsyncOAuthSettings(client_id="111.222", client_secret="valid",) + settings=AsyncOAuthSettings( + client_id="111.222", + client_secret="valid", + ) ), installation_store=store1, ) diff --git a/tests/scenario_tests_async/test_app_bot_only.py b/tests/scenario_tests_async/test_app_bot_only.py index e664269bb..58685393a 100644 --- a/tests/scenario_tests_async/test_app_bot_only.py +++ b/tests/scenario_tests_async/test_app_bot_only.py @@ -29,7 +29,10 @@ class TestAppBotOnly: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = AsyncWebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = AsyncWebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) @pytest.fixture def event_loop(self): @@ -45,7 +48,8 @@ def event_loop(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): diff --git a/tests/scenario_tests_async/test_attachment_actions.py b/tests/scenario_tests_async/test_attachment_actions.py index 34110bd38..00338c68e 100644 --- a/tests/scenario_tests_async/test_attachment_actions.py +++ b/tests/scenario_tests_async/test_attachment_actions.py @@ -21,7 +21,10 @@ class TestAsyncAttachmentActions: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = AsyncWebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = AsyncWebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) @pytest.fixture def event_loop(self): @@ -37,7 +40,8 @@ def event_loop(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -60,7 +64,10 @@ async def test_mock_server_is_running(self): @pytest.mark.asyncio async def test_success_without_type(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.action("pick_channel_for_fun")(simple_listener) request = self.build_valid_request() @@ -70,9 +77,15 @@ async def test_success_without_type(self): @pytest.mark.asyncio async def test_success(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.action( - {"callback_id": "pick_channel_for_fun", "type": "interactive_message",} + { + "callback_id": "pick_channel_for_fun", + "type": "interactive_message", + } )(simple_listener) request = self.build_valid_request() @@ -82,7 +95,10 @@ async def test_success(self): @pytest.mark.asyncio async def test_success_2(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.attachment_action("pick_channel_for_fun")(simple_listener) request = self.build_valid_request() @@ -98,7 +114,10 @@ async def test_process_before_response(self): process_before_response=True, ) app.action( - {"callback_id": "pick_channel_for_fun", "type": "interactive_message",} + { + "callback_id": "pick_channel_for_fun", + "type": "interactive_message", + } )(simple_listener) request = self.build_valid_request() @@ -122,7 +141,10 @@ async def test_process_before_response_2(self): @pytest.mark.asyncio async def test_failure_without_type(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request() response = await app.async_dispatch(request) assert response.status == 404 @@ -135,22 +157,31 @@ async def test_failure_without_type(self): @pytest.mark.asyncio async def test_failure(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request() response = await app.async_dispatch(request) assert response.status == 404 assert self.mock_received_requests["/auth.test"] == 1 - app.action({"callback_id": "unknown", "type": "interactive_message",})( - simple_listener - ) + app.action( + { + "callback_id": "unknown", + "type": "interactive_message", + } + )(simple_listener) response = await app.async_dispatch(request) assert response.status == 404 assert self.mock_received_requests["/auth.test"] == 1 @pytest.mark.asyncio async def test_failure_2(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request() response = await app.async_dispatch(request) assert response.status == 404 diff --git a/tests/scenario_tests_async/test_authorize.py b/tests/scenario_tests_async/test_authorize.py index 83e7d45a3..01a3c4331 100644 --- a/tests/scenario_tests_async/test_authorize.py +++ b/tests/scenario_tests_async/test_authorize.py @@ -26,7 +26,8 @@ async def authorize(enterprise_id, team_id, user_id, client: AsyncWebClient): assert user_id == "W99999" auth_test = await client.auth_test(token=valid_token) return AuthorizeResult.from_auth_test_response( - auth_test_response=auth_test, bot_token=valid_token, + auth_test_response=auth_test, + bot_token=valid_token, ) @@ -36,7 +37,8 @@ async def user_authorize(enterprise_id, team_id, user_id, client: AsyncWebClient assert user_id == "W99999" auth_test = await client.auth_test(token=valid_user_token) return AuthorizeResult.from_auth_test_response( - auth_test_response=auth_test, user_token=valid_user_token, + auth_test_response=auth_test, + user_token=valid_user_token, ) @@ -51,7 +53,10 @@ class TestAsyncAuthorize: signing_secret = "secret" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = AsyncWebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = AsyncWebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) @pytest.fixture def event_loop(self): @@ -67,7 +72,8 @@ def event_loop(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): diff --git a/tests/scenario_tests_async/test_block_actions.py b/tests/scenario_tests_async/test_block_actions.py index 3eab11552..4ee1b1fb1 100644 --- a/tests/scenario_tests_async/test_block_actions.py +++ b/tests/scenario_tests_async/test_block_actions.py @@ -22,7 +22,10 @@ class TestAsyncBlockActions: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = AsyncWebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = AsyncWebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) @pytest.fixture def event_loop(self): @@ -38,7 +41,8 @@ def event_loop(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -61,7 +65,10 @@ async def test_mock_server_is_running(self): @pytest.mark.asyncio async def test_success(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.action("a")(simple_listener) request = self.build_valid_request() @@ -71,7 +78,10 @@ async def test_success(self): @pytest.mark.asyncio async def test_success_2(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.block_action("a")(simple_listener) request = self.build_valid_request() @@ -81,7 +91,10 @@ async def test_success_2(self): @pytest.mark.asyncio async def test_default_type(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.action({"action_id": "a", "block_id": "b"})(simple_listener) request = self.build_valid_request() @@ -91,7 +104,10 @@ async def test_default_type(self): @pytest.mark.asyncio async def test_default_type_no_block_id(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.action({"action_id": "a"})(simple_listener) request = self.build_valid_request() @@ -101,7 +117,10 @@ async def test_default_type_no_block_id(self): @pytest.mark.asyncio async def test_default_type_unmatched_block_id(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.action({"action_id": "a", "block_id": "bbb"})(simple_listener) request = self.build_valid_request() @@ -139,7 +158,10 @@ async def test_process_before_response_2(self): @pytest.mark.asyncio async def test_failure(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request() response = await app.async_dispatch(request) assert response.status == 404 @@ -152,7 +174,10 @@ async def test_failure(self): @pytest.mark.asyncio async def test_failure_2(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request() response = await app.async_dispatch(request) assert response.status == 404 diff --git a/tests/scenario_tests_async/test_block_suggestion.py b/tests/scenario_tests_async/test_block_suggestion.py index b6f7aa80c..7351b290b 100644 --- a/tests/scenario_tests_async/test_block_suggestion.py +++ b/tests/scenario_tests_async/test_block_suggestion.py @@ -22,7 +22,10 @@ class TestAsyncBlockSuggestion: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = AsyncWebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = AsyncWebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) @pytest.fixture def event_loop(self): @@ -38,7 +41,8 @@ def event_loop(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -67,7 +71,10 @@ async def test_mock_server_is_running(self): @pytest.mark.asyncio async def test_success(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.options("es_a")(show_options) request = self.build_valid_request() @@ -79,7 +86,10 @@ async def test_success(self): @pytest.mark.asyncio async def test_success_2(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.block_suggestion("es_a")(show_options) request = self.build_valid_request() @@ -91,7 +101,10 @@ async def test_success_2(self): @pytest.mark.asyncio async def test_success_multi(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.options("mes_a")(show_multi_options) request = self.build_valid_multi_request() @@ -135,7 +148,10 @@ async def test_process_before_response_multi(self): @pytest.mark.asyncio async def test_failure(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request() response = await app.async_dispatch(request) assert response.status == 404 @@ -148,7 +164,10 @@ async def test_failure(self): @pytest.mark.asyncio async def test_failure_2(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request() response = await app.async_dispatch(request) assert response.status == 404 @@ -161,7 +180,10 @@ async def test_failure_2(self): @pytest.mark.asyncio async def test_failure_multi(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_multi_request() response = await app.async_dispatch(request) assert response.status == 404 diff --git a/tests/scenario_tests_async/test_dialogs.py b/tests/scenario_tests_async/test_dialogs.py index 2f99d468f..1cad07ff4 100644 --- a/tests/scenario_tests_async/test_dialogs.py +++ b/tests/scenario_tests_async/test_dialogs.py @@ -21,7 +21,10 @@ class TestAsyncAttachmentActions: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = AsyncWebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = AsyncWebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) @pytest.fixture def event_loop(self): @@ -37,7 +40,8 @@ def event_loop(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -58,7 +62,10 @@ async def test_mock_server_is_running(self): @pytest.mark.asyncio async def test_success_without_type(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.options("dialog-callback-id")(handle_suggestion) app.action("dialog-callback-id")(handle_submission_or_cancellation) @@ -83,7 +90,10 @@ async def test_success_without_type(self): @pytest.mark.asyncio async def test_success(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.options({"type": "dialog_suggestion", "callback_id": "dialog-callback-id"})( handle_suggestion ) @@ -115,7 +125,10 @@ async def test_success(self): @pytest.mark.asyncio async def test_success_2(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.dialog_suggestion("dialog-callback-id")(handle_suggestion) app.dialog_submission("dialog-callback-id")(handle_submission) app.dialog_cancellation("dialog-callback-id")(handle_cancellation) @@ -207,7 +220,10 @@ async def test_process_before_response_2(self): @pytest.mark.asyncio async def test_suggestion_failure_without_type(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request(suggestion_raw_body) response = await app.async_dispatch(request) assert response.status == 404 @@ -220,7 +236,10 @@ async def test_suggestion_failure_without_type(self): @pytest.mark.asyncio async def test_suggestion_failure(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request(suggestion_raw_body) response = await app.async_dispatch(request) assert response.status == 404 @@ -233,7 +252,10 @@ async def test_suggestion_failure(self): @pytest.mark.asyncio async def test_suggestion_failure_2(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request(suggestion_raw_body) response = await app.async_dispatch(request) assert response.status == 404 @@ -248,7 +270,10 @@ async def test_suggestion_failure_2(self): @pytest.mark.asyncio async def test_submission_failure_without_type(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request(suggestion_raw_body) response = await app.async_dispatch(request) assert response.status == 404 @@ -261,7 +286,10 @@ async def test_submission_failure_without_type(self): @pytest.mark.asyncio async def test_submission_failure(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request(suggestion_raw_body) response = await app.async_dispatch(request) assert response.status == 404 @@ -274,7 +302,10 @@ async def test_submission_failure(self): @pytest.mark.asyncio async def test_submission_failure_2(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request(suggestion_raw_body) response = await app.async_dispatch(request) assert response.status == 404 @@ -289,7 +320,10 @@ async def test_submission_failure_2(self): @pytest.mark.asyncio async def test_cancellation_failure_without_type(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request(suggestion_raw_body) response = await app.async_dispatch(request) assert response.status == 404 @@ -302,7 +336,10 @@ async def test_cancellation_failure_without_type(self): @pytest.mark.asyncio async def test_cancellation_failure(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request(suggestion_raw_body) response = await app.async_dispatch(request) assert response.status == 404 @@ -315,7 +352,10 @@ async def test_cancellation_failure(self): @pytest.mark.asyncio async def test_cancellation_failure_2(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request(suggestion_raw_body) response = await app.async_dispatch(request) assert response.status == 404 @@ -402,7 +442,10 @@ async def handle_submission(ack): "value": "UXD-342", }, {"label": "[FE-459] Remove the marquee tag", "value": "FE-459"}, - {"label": "[FE-238] Too many shades of gray in master CSS", "value": "FE-238",}, + { + "label": "[FE-238] Too many shades of gray in master CSS", + "value": "FE-238", + }, ] } diff --git a/tests/scenario_tests_async/test_error_handler.py b/tests/scenario_tests_async/test_error_handler.py index 6a599c5a0..d0e553ff4 100644 --- a/tests/scenario_tests_async/test_error_handler.py +++ b/tests/scenario_tests_async/test_error_handler.py @@ -21,7 +21,10 @@ class TestAsyncErrorHandler: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = AsyncWebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = AsyncWebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) @pytest.fixture def event_loop(self): @@ -41,7 +44,8 @@ def event_loop(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -54,11 +58,15 @@ def build_headers(self, timestamp: str, body: str): def build_valid_request(self) -> AsyncBoltRequest: body = { "type": "block_actions", - "user": {"id": "W111",}, + "user": { + "id": "W111", + }, "api_app_id": "A111", "token": "verification_token", "trigger_id": "111.222.valid", - "team": {"id": "T111",}, + "team": { + "id": "T111", + }, "channel": {"id": "C111", "name": "test-channel"}, "response_url": "https://hooks.slack.com/actions/T111/111/random-value", "actions": [ @@ -87,7 +95,10 @@ async def test_default(self): async def failing_listener(): raise Exception("Something wrong!") - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.action("a")(failing_listener) request = self.build_valid_request() @@ -103,7 +114,10 @@ async def error_handler(logger, payload, response): async def failing_listener(): raise Exception("Something wrong!") - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.error(error_handler) app.action("a")(failing_listener) diff --git a/tests/scenario_tests_async/test_events.py b/tests/scenario_tests_async/test_events.py index 67e02db0b..346883bee 100644 --- a/tests/scenario_tests_async/test_events.py +++ b/tests/scenario_tests_async/test_events.py @@ -22,7 +22,10 @@ class TestAsyncEvents: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = AsyncWebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = AsyncWebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) @pytest.fixture def event_loop(self): @@ -38,7 +41,8 @@ def event_loop(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -59,7 +63,10 @@ async def test_mock_server_is_running(self): @pytest.mark.asyncio async def test_app_mention(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.event("app_mention")(whats_up) request = self.build_valid_app_mention_request() @@ -97,7 +104,10 @@ async def test_middleware_skip(self): @pytest.mark.asyncio async def test_simultaneous_requests(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.event("app_mention")(random_sleeper) request = self.build_valid_app_mention_request() @@ -120,7 +130,10 @@ def build_valid_reaction_added_request(self) -> AsyncBoltRequest: @pytest.mark.asyncio async def test_reaction_added(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.event("reaction_added")(whats_up) request = self.build_valid_reaction_added_request() @@ -132,7 +145,10 @@ async def test_reaction_added(self): @pytest.mark.asyncio async def test_stable_auto_ack(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.event("reaction_added")(always_failing) for _ in range(10): @@ -142,7 +158,10 @@ async def test_stable_auto_ack(self): @pytest.mark.asyncio async def test_self_events(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.event("reaction_added")(whats_up) self_event = { @@ -180,7 +199,10 @@ async def test_self_events(self): @pytest.mark.asyncio async def test_self_joined_left_events(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.event("reaction_added")(whats_up) join_event_body = { @@ -249,7 +271,10 @@ async def handle_member_left_channel(say): @pytest.mark.asyncio async def test_joined_left_events(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.event("reaction_added")(whats_up) join_event_body = { diff --git a/tests/scenario_tests_async/test_events_org_apps.py b/tests/scenario_tests_async/test_events_org_apps.py index 04182d937..596927879 100644 --- a/tests/scenario_tests_async/test_events_org_apps.py +++ b/tests/scenario_tests_async/test_events_org_apps.py @@ -68,7 +68,8 @@ def event_loop(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): diff --git a/tests/scenario_tests_async/test_events_shared_channels.py b/tests/scenario_tests_async/test_events_shared_channels.py index 0fb85f11d..b7877cf15 100644 --- a/tests/scenario_tests_async/test_events_shared_channels.py +++ b/tests/scenario_tests_async/test_events_shared_channels.py @@ -25,7 +25,8 @@ async def authorize(enterprise_id, team_id, client: AsyncWebClient): assert team_id == "T_INSTALLED" auth_test = await client.auth_test(token=valid_token) return AuthorizeResult.from_auth_test_response( - auth_test_response=auth_test, bot_token=valid_token, + auth_test_response=auth_test, + bot_token=valid_token, ) @@ -50,7 +51,8 @@ def event_loop(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): diff --git a/tests/scenario_tests_async/test_events_socket_mode.py b/tests/scenario_tests_async/test_events_socket_mode.py index d668f963c..ce6485f41 100644 --- a/tests/scenario_tests_async/test_events_socket_mode.py +++ b/tests/scenario_tests_async/test_events_socket_mode.py @@ -17,7 +17,10 @@ class TestAsyncEvents: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" - web_client = AsyncWebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = AsyncWebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) @pytest.fixture def event_loop(self): @@ -53,7 +56,10 @@ async def test_app_mention(self): @pytest.mark.asyncio async def test_process_before_response(self): - app = AsyncApp(client=self.web_client, process_before_response=True,) + app = AsyncApp( + client=self.web_client, + process_before_response=True, + ) app.event("app_mention")(whats_up) request = self.build_valid_app_mention_request() diff --git a/tests/scenario_tests_async/test_lazy.py b/tests/scenario_tests_async/test_lazy.py index 229c7709b..f8fe438bc 100644 --- a/tests/scenario_tests_async/test_lazy.py +++ b/tests/scenario_tests_async/test_lazy.py @@ -21,7 +21,10 @@ class TestAsyncLazy: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = AsyncWebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = AsyncWebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) @pytest.fixture def event_loop(self): @@ -41,7 +44,8 @@ def event_loop(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -54,11 +58,15 @@ def build_headers(self, timestamp: str, body: str): def build_valid_request(self) -> AsyncBoltRequest: body = { "type": "block_actions", - "user": {"id": "W111",}, + "user": { + "id": "W111", + }, "api_app_id": "A111", "token": "verification_token", "trigger_id": "111.222.valid", - "team": {"id": "T111",}, + "team": { + "id": "T111", + }, "channel": {"id": "C111", "name": "test-channel"}, "response_url": "https://hooks.slack.com/actions/T111/111/random-value", "actions": [ @@ -95,9 +103,13 @@ async def async2(say): await asyncio.sleep(0.5) await say(text="lazy function 2") - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.action("a")( - ack=just_ack, lazy=[async1, async2], + ack=just_ack, + lazy=[async1, async2], ) request = self.build_valid_request() diff --git a/tests/scenario_tests_async/test_message.py b/tests/scenario_tests_async/test_message.py index c2d6dda52..60ed2e458 100644 --- a/tests/scenario_tests_async/test_message.py +++ b/tests/scenario_tests_async/test_message.py @@ -21,7 +21,10 @@ class TestAsyncMessage: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = AsyncWebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = AsyncWebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) @pytest.fixture def event_loop(self): @@ -37,7 +40,8 @@ def event_loop(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -57,7 +61,10 @@ def build_request2(self) -> AsyncBoltRequest: @pytest.mark.asyncio async def test_string_keyword(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.message("Hello")(whats_up) request = self.build_request() @@ -69,7 +76,10 @@ async def test_string_keyword(self): @pytest.mark.asyncio async def test_string_keyword_capturing(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.message("We've received ([0-9]+) messages from (.+)!")(verify_matches) request = self.build_request2() @@ -81,7 +91,10 @@ async def test_string_keyword_capturing(self): @pytest.mark.asyncio async def test_string_keyword_capturing2(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.message(re.compile("We've received ([0-9]+) messages from (.+)!"))( verify_matches ) @@ -95,7 +108,10 @@ async def test_string_keyword_capturing2(self): @pytest.mark.asyncio async def test_string_keyword_unmatched(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.message("HELLO")(whats_up) request = self.build_request() @@ -105,7 +121,10 @@ async def test_string_keyword_unmatched(self): @pytest.mark.asyncio async def test_regexp_keyword(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.message(re.compile("He.lo"))(whats_up) request = self.build_request() @@ -117,7 +136,10 @@ async def test_regexp_keyword(self): @pytest.mark.asyncio async def test_regexp_keyword_unmatched(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.message(re.compile("HELLO"))(whats_up) request = self.build_request() diff --git a/tests/scenario_tests_async/test_middleware.py b/tests/scenario_tests_async/test_middleware.py index 3b81a387f..bcc8d4baf 100644 --- a/tests/scenario_tests_async/test_middleware.py +++ b/tests/scenario_tests_async/test_middleware.py @@ -20,7 +20,10 @@ class TestAsyncMiddleware: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = AsyncWebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = AsyncWebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) @pytest.fixture def event_loop(self): @@ -56,7 +59,8 @@ def build_request(self) -> AsyncBoltRequest: "content-type": ["application/json"], "x-slack-signature": [ self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) ], "x-slack-request-timestamp": [timestamp], @@ -65,7 +69,10 @@ def build_request(self) -> AsyncBoltRequest: @pytest.mark.asyncio async def test_no_next_call(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.use(no_next) app.shortcut("test-shortcut")(just_ack) @@ -75,7 +82,10 @@ async def test_no_next_call(self): @pytest.mark.asyncio async def test_next_call(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.use(just_next) app.shortcut("test-shortcut")(just_ack) diff --git a/tests/scenario_tests_async/test_shortcut.py b/tests/scenario_tests_async/test_shortcut.py index aac7cde89..5627198af 100644 --- a/tests/scenario_tests_async/test_shortcut.py +++ b/tests/scenario_tests_async/test_shortcut.py @@ -21,7 +21,10 @@ class TestAsyncShortcut: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = AsyncWebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = AsyncWebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) @pytest.fixture def event_loop(self): @@ -37,7 +40,8 @@ def event_loop(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -59,7 +63,10 @@ async def test_mock_server_is_running(self): # NOTE: This is a compatible behavior with Bolt for JS @pytest.mark.asyncio async def test_success_both_global_and_message(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.shortcut("test-shortcut")(simple_listener) request = self.build_valid_request(global_shortcut_raw_body) @@ -74,7 +81,10 @@ async def test_success_both_global_and_message(self): @pytest.mark.asyncio async def test_success_global(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.shortcut("test-shortcut")(simple_listener) request = self.build_valid_request(global_shortcut_raw_body) @@ -84,7 +94,10 @@ async def test_success_global(self): @pytest.mark.asyncio async def test_success_global_2(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.global_shortcut("test-shortcut")(simple_listener) request = self.build_valid_request(global_shortcut_raw_body) @@ -99,7 +112,10 @@ async def test_success_global_2(self): @pytest.mark.asyncio async def test_success_message(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.shortcut({"type": "message_action", "callback_id": "test-shortcut"})( simple_listener ) @@ -116,7 +132,10 @@ async def test_success_message(self): @pytest.mark.asyncio async def test_success_message_2(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.message_shortcut("test-shortcut")(simple_listener) request = self.build_valid_request(message_shortcut_raw_body) @@ -145,7 +164,10 @@ async def test_process_before_response_global(self): @pytest.mark.asyncio async def test_failure(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request(global_shortcut_raw_body) response = await app.async_dispatch(request) assert response.status == 404 @@ -158,7 +180,10 @@ async def test_failure(self): @pytest.mark.asyncio async def test_failure_2(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request(global_shortcut_raw_body) response = await app.async_dispatch(request) assert response.status == 404 diff --git a/tests/scenario_tests_async/test_slash_command.py b/tests/scenario_tests_async/test_slash_command.py index 84d8a44eb..44c881b9a 100644 --- a/tests/scenario_tests_async/test_slash_command.py +++ b/tests/scenario_tests_async/test_slash_command.py @@ -20,7 +20,10 @@ class TestAsyncSlashCommand: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = AsyncWebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = AsyncWebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) @pytest.fixture def event_loop(self): @@ -36,7 +39,8 @@ def event_loop(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -57,7 +61,10 @@ async def test_mock_server_is_running(self): @pytest.mark.asyncio async def test_success(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.command("/hello-world")(commander) request = self.build_valid_request() @@ -81,7 +88,10 @@ async def test_process_before_response(self): @pytest.mark.asyncio async def test_failure(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request() response = await app.async_dispatch(request) assert response.status == 404 diff --git a/tests/scenario_tests_async/test_ssl_check.py b/tests/scenario_tests_async/test_ssl_check.py index 3a22e85b8..651255903 100644 --- a/tests/scenario_tests_async/test_ssl_check.py +++ b/tests/scenario_tests_async/test_ssl_check.py @@ -19,7 +19,10 @@ class TestAsyncSSLCheck: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = AsyncWebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = AsyncWebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) @pytest.fixture def event_loop(self): @@ -35,7 +38,8 @@ def event_loop(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) @pytest.mark.asyncio diff --git a/tests/scenario_tests_async/test_view_closed.py b/tests/scenario_tests_async/test_view_closed.py index 020301284..d5af6167c 100644 --- a/tests/scenario_tests_async/test_view_closed.py +++ b/tests/scenario_tests_async/test_view_closed.py @@ -21,7 +21,10 @@ class TestAsyncViewClosed: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = AsyncWebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = AsyncWebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) @pytest.fixture def event_loop(self): @@ -37,7 +40,8 @@ def event_loop(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -60,7 +64,10 @@ async def test_mock_server_is_running(self): @pytest.mark.asyncio async def test_success(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.view({"type": "view_closed", "callback_id": "view-id"})(simple_listener) request = self.build_valid_request() @@ -70,7 +77,10 @@ async def test_success(self): @pytest.mark.asyncio async def test_success_2(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.view_closed("view-id")(simple_listener) request = self.build_valid_request() @@ -94,7 +104,10 @@ async def test_process_before_response(self): @pytest.mark.asyncio async def test_failure(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request() response = await app.async_dispatch(request) assert response.status == 404 @@ -107,7 +120,10 @@ async def test_failure(self): @pytest.mark.asyncio async def test_failure(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request() response = await app.async_dispatch(request) assert response.status == 404 @@ -120,7 +136,10 @@ async def test_failure(self): @pytest.mark.asyncio async def test_failure_2(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request() response = await app.async_dispatch(request) assert response.status == 404 @@ -156,7 +175,10 @@ async def test_failure_2(self): { "type": "input", "block_id": "hspI", - "label": {"type": "plain_text", "text": "Label",}, + "label": { + "type": "plain_text", + "text": "Label", + }, "optional": False, "element": {"type": "plain_text_input", "action_id": "maBWU"}, } @@ -165,11 +187,20 @@ async def test_failure_2(self): "callback_id": "view-id", "state": {"values": {}}, "hash": "1596530361.3wRYuk3R", - "title": {"type": "plain_text", "text": "My App",}, + "title": { + "type": "plain_text", + "text": "My App", + }, "clear_on_close": False, "notify_on_close": False, - "close": {"type": "plain_text", "text": "Cancel",}, - "submit": {"type": "plain_text", "text": "Submit",}, + "close": { + "type": "plain_text", + "text": "Cancel", + }, + "submit": { + "type": "plain_text", + "text": "Submit", + }, "previous_view_id": None, "root_view_id": "V111", "app_id": "A111", diff --git a/tests/scenario_tests_async/test_view_submission.py b/tests/scenario_tests_async/test_view_submission.py index 4c5fa672d..2d7e1d993 100644 --- a/tests/scenario_tests_async/test_view_submission.py +++ b/tests/scenario_tests_async/test_view_submission.py @@ -21,7 +21,10 @@ class TestAsyncViewSubmission: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = AsyncWebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = AsyncWebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) @pytest.fixture def event_loop(self): @@ -37,7 +40,8 @@ def event_loop(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): @@ -60,7 +64,10 @@ async def test_mock_server_is_running(self): @pytest.mark.asyncio async def test_success(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.view("view-id")(simple_listener) request = self.build_valid_request() @@ -70,7 +77,10 @@ async def test_success(self): @pytest.mark.asyncio async def test_success_2(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) app.view_submission("view-id")(simple_listener) request = self.build_valid_request() @@ -94,7 +104,10 @@ async def test_process_before_response(self): @pytest.mark.asyncio async def test_failure(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request() response = await app.async_dispatch(request) assert response.status == 404 @@ -107,7 +120,10 @@ async def test_failure(self): @pytest.mark.asyncio async def test_failure_2(self): - app = AsyncApp(client=self.web_client, signing_secret=self.signing_secret,) + app = AsyncApp( + client=self.web_client, + signing_secret=self.signing_secret, + ) request = self.build_valid_request() response = await app.async_dispatch(request) assert response.status == 404 @@ -144,7 +160,10 @@ async def test_failure_2(self): { "type": "input", "block_id": "hspI", - "label": {"type": "plain_text", "text": "Label",}, + "label": { + "type": "plain_text", + "text": "Label", + }, "optional": False, "element": {"type": "plain_text_input", "action_id": "maBWU"}, } @@ -155,11 +174,20 @@ async def test_failure_2(self): "values": {"hspI": {"maBWU": {"type": "plain_text_input", "value": "test"}}} }, "hash": "1596530361.3wRYuk3R", - "title": {"type": "plain_text", "text": "My App",}, + "title": { + "type": "plain_text", + "text": "My App", + }, "clear_on_close": False, "notify_on_close": False, - "close": {"type": "plain_text", "text": "Cancel",}, - "submit": {"type": "plain_text", "text": "Submit",}, + "close": { + "type": "plain_text", + "text": "Cancel", + }, + "submit": { + "type": "plain_text", + "text": "Submit", + }, "previous_view_id": None, "root_view_id": "V111", "app_id": "A111", diff --git a/tests/scenario_tests_async/test_workflow_steps.py b/tests/scenario_tests_async/test_workflow_steps.py index 525a6f568..0d36ef99b 100644 --- a/tests/scenario_tests_async/test_workflow_steps.py +++ b/tests/scenario_tests_async/test_workflow_steps.py @@ -27,7 +27,10 @@ class TestAsyncWorkflowSteps: valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" signature_verifier = SignatureVerifier(signing_secret) - web_client = AsyncWebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = AsyncWebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) @pytest.fixture def event_loop(self): @@ -43,7 +46,8 @@ def event_loop(self): def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_app(self, callback_id: str): @@ -381,7 +385,10 @@ async def edit(ack: AsyncAck, step, configure: AsyncConfigure): "element": { "type": "plain_text_input", "action_id": "task_name", - "placeholder": {"type": "plain_text", "text": "Write a task name",}, + "placeholder": { + "type": "plain_text", + "text": "Write a task name", + }, }, "label": {"type": "plain_text", "text": "Task name"}, }, @@ -404,7 +411,10 @@ async def edit(ack: AsyncAck, step, configure: AsyncConfigure): "element": { "type": "plain_text_input", "action_id": "task_author", - "placeholder": {"type": "plain_text", "text": "Write a task name",}, + "placeholder": { + "type": "plain_text", + "text": "Write a task name", + }, }, "label": {"type": "plain_text", "text": "Task author"}, }, @@ -431,9 +441,21 @@ async def save(ack: AsyncAck, step: dict, view: dict, update: AsyncUpdate): }, }, outputs=[ - {"name": "taskName", "type": "text", "label": "Task Name",}, - {"name": "taskDescription", "type": "text", "label": "Task Description",}, - {"name": "taskAuthorEmail", "type": "text", "label": "Task Author Email",}, + { + "name": "taskName", + "type": "text", + "label": "Task Name", + }, + { + "name": "taskDescription", + "type": "text", + "label": "Task Description", + }, + { + "name": "taskAuthorEmail", + "type": "text", + "label": "Task Author Email", + }, ], ) await ack() @@ -506,7 +528,8 @@ async def save_lazy(step: dict, view: dict, update: AsyncUpdate): assert step is not None assert view is not None await update( - inputs={}, outputs=[], + inputs={}, + outputs=[], ) diff --git a/tests/slack_bolt/app/test_dev_server.py b/tests/slack_bolt/app/test_dev_server.py index 7e09c6102..978cffc3f 100644 --- a/tests/slack_bolt/app/test_dev_server.py +++ b/tests/slack_bolt/app/test_dev_server.py @@ -12,7 +12,10 @@ class TestDevServer: signing_secret = "secret" valid_token = "xoxb-valid" mock_api_server_base_url = "http://localhost:8888" - web_client = WebClient(token=valid_token, base_url=mock_api_server_base_url,) + web_client = WebClient( + token=valid_token, + base_url=mock_api_server_base_url, + ) def setup_method(self): self.old_os_env = remove_os_env_temporarily() diff --git a/tests/slack_bolt/context/test_ack.py b/tests/slack_bolt/context/test_ack.py index 9ecb17a69..e7d7443e9 100644 --- a/tests/slack_bolt/context/test_ack.py +++ b/tests/slack_bolt/context/test_ack.py @@ -138,8 +138,14 @@ def test_view_update(self): view={ "type": "modal", "callback_id": "view-id", - "title": {"type": "plain_text", "text": "My App",}, - "close": {"type": "plain_text", "text": "Cancel",}, + "title": { + "type": "plain_text", + "text": "My App", + }, + "close": { + "type": "plain_text", + "text": "Cancel", + }, "blocks": [{"type": "divider", "block_id": "b"}], }, ) diff --git a/tests/slack_bolt/listener_matcher/test_custom_listener_matcher.py b/tests/slack_bolt/listener_matcher/test_custom_listener_matcher.py index e241298d5..5a680f137 100644 --- a/tests/slack_bolt/listener_matcher/test_custom_listener_matcher.py +++ b/tests/slack_bolt/listener_matcher/test_custom_listener_matcher.py @@ -19,7 +19,8 @@ def teardown_method(self): def test_instantiation(self): matcher: ListenerMatcher = CustomListenerMatcher( - app_name="foo", func=func, + app_name="foo", + func=func, ) resp = BoltResponse(status=201) diff --git a/tests/slack_bolt/middleware/request_verification/test_request_verification.py b/tests/slack_bolt/middleware/request_verification/test_request_verification.py index dca98e7b6..4fdb28964 100644 --- a/tests/slack_bolt/middleware/request_verification/test_request_verification.py +++ b/tests/slack_bolt/middleware/request_verification/test_request_verification.py @@ -17,7 +17,8 @@ class TestRequestVerification: def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): diff --git a/tests/slack_bolt_async/app/test_server.py b/tests/slack_bolt_async/app/test_server.py index 1c8bbfc29..0c53f96c4 100644 --- a/tests/slack_bolt_async/app/test_server.py +++ b/tests/slack_bolt_async/app/test_server.py @@ -13,6 +13,9 @@ def test_instance(self): server = AsyncSlackAppServer( port=3001, path="/slack/events", - app=AsyncApp(signing_secret="valid", token="xoxb-valid",), + app=AsyncApp( + signing_secret="valid", + token="xoxb-valid", + ), ) assert server is not None diff --git a/tests/slack_bolt_async/authorization/test_async_authorize.py b/tests/slack_bolt_async/authorization/test_async_authorize.py index f8a3cc98c..f81927c86 100644 --- a/tests/slack_bolt_async/authorization/test_async_authorize.py +++ b/tests/slack_bolt_async/authorization/test_async_authorize.py @@ -22,7 +22,9 @@ class TestAsyncAuthorize: mock_api_server_base_url = "http://localhost:8888" - client = AsyncWebClient(base_url=mock_api_server_base_url,) + client = AsyncWebClient( + base_url=mock_api_server_base_url, + ) @pytest.fixture def event_loop(self): diff --git a/tests/slack_bolt_async/context/test_async_ack.py b/tests/slack_bolt_async/context/test_async_ack.py index fa74e198f..6004002dd 100644 --- a/tests/slack_bolt_async/context/test_async_ack.py +++ b/tests/slack_bolt_async/context/test_async_ack.py @@ -145,8 +145,14 @@ async def test_view_update(self): view={ "type": "modal", "callbAsyncAck_id": "view-id", - "title": {"type": "plain_text", "text": "My App",}, - "close": {"type": "plain_text", "text": "Cancel",}, + "title": { + "type": "plain_text", + "text": "My App", + }, + "close": { + "type": "plain_text", + "text": "Cancel", + }, "blocks": [{"type": "divider", "block_id": "b"}], }, ) diff --git a/tests/slack_bolt_async/listener_matcher/test_async_custom_listener_matcher.py b/tests/slack_bolt_async/listener_matcher/test_async_custom_listener_matcher.py index 6e226c9b6..96a407aab 100644 --- a/tests/slack_bolt_async/listener_matcher/test_async_custom_listener_matcher.py +++ b/tests/slack_bolt_async/listener_matcher/test_async_custom_listener_matcher.py @@ -20,7 +20,8 @@ class TestAsyncCustomListenerMatcher: @pytest.mark.asyncio async def test_instantiation(self): matcher: AsyncListenerMatcher = AsyncCustomListenerMatcher( - app_name="foo", func=func, + app_name="foo", + func=func, ) resp = BoltResponse(status=201) diff --git a/tests/slack_bolt_async/middleware/request_verification/test_request_verification.py b/tests/slack_bolt_async/middleware/request_verification/test_request_verification.py index 783927572..098db8b09 100644 --- a/tests/slack_bolt_async/middleware/request_verification/test_request_verification.py +++ b/tests/slack_bolt_async/middleware/request_verification/test_request_verification.py @@ -21,7 +21,8 @@ class TestAsyncRequestVerification: def generate_signature(self, body: str, timestamp: str): return self.signature_verifier.generate_signature( - body=body, timestamp=timestamp, + body=body, + timestamp=timestamp, ) def build_headers(self, timestamp: str, body: str): diff --git a/tests/slack_bolt_async/oauth/test_async_oauth_flow.py b/tests/slack_bolt_async/oauth/test_async_oauth_flow.py index 44f4e5ea7..af5adbbd2 100644 --- a/tests/slack_bolt_async/oauth/test_async_oauth_flow.py +++ b/tests/slack_bolt_async/oauth/test_async_oauth_flow.py @@ -203,7 +203,8 @@ async def failure(args: AsyncFailureArgs) -> BoltResponse: installation_store=FileInstallationStore(), state_store=FileOAuthStateStore(expiration_seconds=120), callback_options=AsyncCallbackOptions( - success=success, failure=failure, + success=success, + failure=failure, ), ), ) diff --git a/tests/slack_bolt_async/oauth/test_async_oauth_flow_sqlite3.py b/tests/slack_bolt_async/oauth/test_async_oauth_flow_sqlite3.py index 3c17ca49e..afd3cbdac 100644 --- a/tests/slack_bolt_async/oauth/test_async_oauth_flow_sqlite3.py +++ b/tests/slack_bolt_async/oauth/test_async_oauth_flow_sqlite3.py @@ -113,7 +113,10 @@ async def failure(args: AsyncFailureArgs) -> BoltResponse: client_id="111.222", client_secret="xxx", scopes=["chat:write", "commands"], - callback_options=AsyncCallbackOptions(success=success, failure=failure,), + callback_options=AsyncCallbackOptions( + success=success, + failure=failure, + ), ) state = await oauth_flow.issue_new_state(None) req = AsyncBoltRequest(