From ffc67d75941d6aa277233b7c4c56f009a4595ff1 Mon Sep 17 00:00:00 2001 From: Max Neuvians Date: Fri, 26 Jan 2024 16:22:33 +0000 Subject: [PATCH] fix: lint --- app/commands/secret.py | 5 +++-- app/tests/commands/test_secret.py | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/commands/secret.py b/app/commands/secret.py index bc4d9f7f..5bc53198 100644 --- a/app/commands/secret.py +++ b/app/commands/secret.py @@ -21,7 +21,7 @@ def secret_command(client, ack, command, body): client.views_open(trigger_id=body["trigger_id"], view=view) -def secret_view_handler(ack, client, view): +def secret_view_handler(ack, client, view, logger): ack() locale = view["blocks"][0]["elements"][0]["value"] i18n.set("locale", locale) @@ -43,7 +43,8 @@ def secret_view_handler(ack, client, view): user=view["private_metadata"], text=f"{i18n.t('secret.link_available')} {url}", ) - except: + except Exception as e: + logger.error(e) client.chat_postEphemeral( channel=view["private_metadata"], user=view["private_metadata"], diff --git a/app/tests/commands/test_secret.py b/app/tests/commands/test_secret.py index ab2b2838..6813b629 100644 --- a/app/tests/commands/test_secret.py +++ b/app/tests/commands/test_secret.py @@ -1,8 +1,6 @@ -import datetime - from commands import secret -from unittest.mock import call, MagicMock, patch +from unittest.mock import MagicMock, patch @patch("commands.secret.generate_secret_command_modal_view") @@ -38,6 +36,7 @@ def test_secret_command(mock_get_user_locale, mock_generate_secret_command_modal def test_secret_view_handler_with_succesfull_request(mock_time, mock_requests): ack = MagicMock() client = MagicMock() + logger = MagicMock() view = { "blocks": [ { @@ -71,7 +70,7 @@ def test_secret_view_handler_with_succesfull_request(mock_time, mock_requests): mock_requests.post.return_value.json.return_value = {"id": "id"} - secret.secret_view_handler(ack, client, view) + secret.secret_view_handler(ack, client, view, logger) ack.assert_called_once_with() @@ -94,6 +93,7 @@ def test_secret_view_handler_with_succesfull_request(mock_time, mock_requests): def test_secret_view_handler_with_failed_request(mock_time, mock_requests): ack = MagicMock() client = MagicMock() + logger = MagicMock() view = { "blocks": [ { @@ -127,7 +127,7 @@ def test_secret_view_handler_with_failed_request(mock_time, mock_requests): mock_requests.post.return_value.json.return_value = {} - secret.secret_view_handler(ack, client, view) + secret.secret_view_handler(ack, client, view, logger) ack.assert_called_once_with()