diff --git a/slack_sdk/web/deprecation.py b/slack_sdk/web/deprecation.py index 6fa52522..5f7f8748 100644 --- a/slack_sdk/web/deprecation.py +++ b/slack_sdk/web/deprecation.py @@ -12,6 +12,8 @@ deprecated_method_prefixes_2023_07 = ["stars."] +deprecated_method_prefixes_2024_09 = ["workflows.stepCompleted", "workflows.updateStep", "workflows.stepFailed"] + def show_deprecation_warning_if_any(method_name: str): """Prints a warning if the given method is deprecated""" @@ -40,3 +42,12 @@ def show_deprecation_warning_if_any(method_name: str): "https://api.slack.com/changelog/2023-07-its-later-already-for-stars-and-reminders" ) warnings.warn(message) + + # 2024/09 workflow steps API deprecation + matched_prefixes = [prefix for prefix in deprecated_method_prefixes_2024_09 if method_name.startswith(prefix)] + if len(matched_prefixes) > 0: + message = ( + f"{method_name} is deprecated. For more info, go to " + "https://api.slack.com/changelog/2023-08-workflow-steps-from-apps-step-back" + ) + warnings.warn(message) diff --git a/tests/slack_sdk/web/test_web_client_workflow_step_deprecation.py b/tests/slack_sdk/web/test_web_client_workflow_step_deprecation.py new file mode 100644 index 00000000..397f600e --- /dev/null +++ b/tests/slack_sdk/web/test_web_client_workflow_step_deprecation.py @@ -0,0 +1,35 @@ +import unittest +import pytest + +from slack_sdk.web import WebClient +from tests.helpers import remove_os_env_temporarily, restore_os_env +from tests.slack_sdk.web.mock_web_api_server import ( + setup_mock_web_api_server, + cleanup_mock_web_api_server, +) + + +class TestWebClient(unittest.TestCase): + def setUp(self): + setup_mock_web_api_server(self) + self.env_values = remove_os_env_temporarily() + + def tearDown(self): + cleanup_mock_web_api_server(self) + restore_os_env(self.env_values) + + # You can enable this test to verify if the warning can be printed as expected + @pytest.mark.skip() + def test_workflow_step_completed_deprecation(self): + client = WebClient(base_url="http://localhost:8888") + client.workflows_stepCompleted(token="xoxb-api_test", workflow_step_execute_id="W1234") + + @pytest.mark.skip() + def test_workflow_step_failed_deprecation(self): + client = WebClient(base_url="http://localhost:8888") + client.workflows_stepFailed(token="xoxb-api_test", workflow_step_execute_id="W1234", error={}) + + @pytest.mark.skip() + def test_workflow_update_step_deprecation(self): + client = WebClient(base_url="http://localhost:8888") + client.workflows_updateStep(token="xoxb-api_test", workflow_step_edit_id="W1234", inputs={}, outputs={})