From 25e0c959cac55ff1dca1c1b9be2a469113c65b46 Mon Sep 17 00:00:00 2001 From: hughhhh Date: Wed, 16 Feb 2022 10:40:47 -0800 Subject: [PATCH 1/3] update url for slack reports --- superset/reports/notifications/slack.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/superset/reports/notifications/slack.py b/superset/reports/notifications/slack.py index 8fb01581762c6..b833cbd53ddf3 100644 --- a/superset/reports/notifications/slack.py +++ b/superset/reports/notifications/slack.py @@ -29,6 +29,7 @@ from superset.models.reports import ReportRecipientType from superset.reports.notifications.base import BaseNotification from superset.reports.notifications.exceptions import NotificationError +from superset.utils.urls import modify_url_query logger = logging.getLogger(__name__) @@ -47,6 +48,11 @@ def _get_channel(self) -> str: return json.loads(self._recipient.recipient_config_json)["target"] def _message_template(self, table: str = "") -> str: + url = ( + modify_url_query(self._content.url, standalone="0") + if self._content.url is not None + else "" + ) return __( """*%(name)s* @@ -58,7 +64,7 @@ def _message_template(self, table: str = "") -> str: """, name=self._content.name, description=self._content.description or "", - url=self._content.url, + url=url, table=table, ) From 903aa4e356c84a8b3dc9372fb412dfbdcdcebeae Mon Sep 17 00:00:00 2001 From: hughhhh Date: Wed, 16 Feb 2022 15:55:30 -0800 Subject: [PATCH 2/3] fix test --- tests/integration_tests/reports/commands_tests.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/integration_tests/reports/commands_tests.py b/tests/integration_tests/reports/commands_tests.py index f03666ec9aded..2b9237a96435e 100644 --- a/tests/integration_tests/reports/commands_tests.py +++ b/tests/integration_tests/reports/commands_tests.py @@ -1024,6 +1024,7 @@ def test_slack_chart_report_schedule( notification_targets = get_target_from_report_schedule( create_report_slack_chart ) + assert file_upload_mock.call_args[1]["channels"] == notification_targets[0] assert file_upload_mock.call_args[1]["file"] == SCREENSHOT_FILE @@ -1119,6 +1120,11 @@ def test_slack_chart_report_schedule_with_text( | 1 | c21 | c22 | c23 |""" assert table_markdown in post_message_mock.call_args[1]["text"] + print(post_message_mock.call_args[1]["text"]) + assert ( + f"http://0.0.0.0:8080/superset/explore/?form_data=%7B%22slice_id%22%3A%201%7D&standalone=0&force=false" + ) in post_message_mock.call_args[1]["text"] + # Assert logs are correct assert_log(ReportState.SUCCESS) From fda885d2474dcf62feae3ec62737f34390fa9c0d Mon Sep 17 00:00:00 2001 From: hughhhh Date: Thu, 17 Feb 2022 12:56:38 -0500 Subject: [PATCH 3/3] update text to be dynamic --- tests/integration_tests/reports/commands_tests.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/integration_tests/reports/commands_tests.py b/tests/integration_tests/reports/commands_tests.py index 2b9237a96435e..68effd2c7fcb6 100644 --- a/tests/integration_tests/reports/commands_tests.py +++ b/tests/integration_tests/reports/commands_tests.py @@ -1119,11 +1119,10 @@ def test_slack_chart_report_schedule_with_text( | 0 | c11 | c12 | c13 | | 1 | c21 | c22 | c23 |""" assert table_markdown in post_message_mock.call_args[1]["text"] - - print(post_message_mock.call_args[1]["text"]) assert ( - f"http://0.0.0.0:8080/superset/explore/?form_data=%7B%22slice_id%22%3A%201%7D&standalone=0&force=false" - ) in post_message_mock.call_args[1]["text"] + f"" + in post_message_mock.call_args[1]["text"] + ) # Assert logs are correct assert_log(ReportState.SUCCESS)