From d5acbee1f72dd405529a8f20931ab084228c4d42 Mon Sep 17 00:00:00 2001 From: Michal Cieszynski Date: Wed, 10 Jul 2024 08:34:02 +0900 Subject: [PATCH 1/2] fix: replace unsupported slack operation --- superset/reports/notifications/slack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset/reports/notifications/slack.py b/superset/reports/notifications/slack.py index 6a6bbda7bac7d..820913d9a9e07 100644 --- a/superset/reports/notifications/slack.py +++ b/superset/reports/notifications/slack.py @@ -210,7 +210,7 @@ def _deprecated_upload_files( for channel in recipients: if len(files) > 0: for file in files: - client.files_upload( + client.files_upload_v2( channels=channel, file=file, initial_comment=body, From cff96ac3b33c72ec3e9d355c6671c512667251b3 Mon Sep 17 00:00:00 2001 From: Michal Cieszynski Date: Wed, 10 Jul 2024 08:43:04 +0900 Subject: [PATCH 2/2] fix: Replace unsupported Slack API with new method calls --- superset/reports/notifications/slack.py | 2 +- tests/integration_tests/reports/commands_tests.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/superset/reports/notifications/slack.py b/superset/reports/notifications/slack.py index 820913d9a9e07..6976bb59d2232 100644 --- a/superset/reports/notifications/slack.py +++ b/superset/reports/notifications/slack.py @@ -246,7 +246,7 @@ def send(self) -> None: files = self._get_inline_files() - # files_upload returns SlackResponse as we run it in sync mode. + # files_upload_v2 returns SlackResponse as we run it in sync mode. for channel in channels: if len(files) > 0: for file in files: diff --git a/tests/integration_tests/reports/commands_tests.py b/tests/integration_tests/reports/commands_tests.py index 3936888b03ffd..945d79cf7d35f 100644 --- a/tests/integration_tests/reports/commands_tests.py +++ b/tests/integration_tests/reports/commands_tests.py @@ -1172,11 +1172,11 @@ def test_slack_chart_report_schedule_deprecated( ).run() assert ( - slack_client_mock.return_value.files_upload.call_args[1]["channels"] + slack_client_mock.return_value.files_upload_v2.call_args[1]["channels"] == channel_name ) assert ( - slack_client_mock.return_value.files_upload.call_args[1]["file"] + slack_client_mock.return_value.files_upload_v2.call_args[1]["file"] == SCREENSHOT_FILE ) @@ -1332,11 +1332,11 @@ def test_slack_chart_report_schedule_with_csv_deprecated_api( ).run() assert ( - slack_client_mock_class.return_value.files_upload.call_args[1]["channels"] + slack_client_mock_class.return_value.files_upload_v2.call_args[1]["channels"] == channel_name ) assert ( - slack_client_mock_class.return_value.files_upload.call_args[1]["file"] + slack_client_mock_class.return_value.files_upload_v2.call_args[1]["file"] == CSV_FILE ) @@ -1577,7 +1577,7 @@ def test_report_schedule_success_grace(create_alert_slack_chart_success): @pytest.mark.usefixtures("create_alert_slack_chart_grace") -@patch("superset.utils.slack.WebClient.files_upload") +@patch("superset.utils.slack.WebClient.files_upload_v2") @patch("superset.utils.screenshots.ChartScreenshot.get_screenshot") @patch("superset.reports.notifications.slack.get_slack_client") def test_report_schedule_success_grace_end(