Skip to content

Commit 5f941f4

Browse files
fix: Add deprecation warnings to Steps from Apps methods (#1504)
* Added deprecation warnings for workflow step deprecation * Update format
1 parent 7d13c3b commit 5f941f4

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

slack_sdk/web/deprecation.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
deprecated_method_prefixes_2023_07 = ["stars."]
1414

15+
deprecated_method_prefixes_2024_09 = ["workflows.stepCompleted", "workflows.updateStep", "workflows.stepFailed"]
16+
1517

1618
def show_deprecation_warning_if_any(method_name: str):
1719
"""Prints a warning if the given method is deprecated"""
@@ -40,3 +42,12 @@ def show_deprecation_warning_if_any(method_name: str):
4042
"https://api.slack.com/changelog/2023-07-its-later-already-for-stars-and-reminders"
4143
)
4244
warnings.warn(message)
45+
46+
# 2024/09 workflow steps API deprecation
47+
matched_prefixes = [prefix for prefix in deprecated_method_prefixes_2024_09 if method_name.startswith(prefix)]
48+
if len(matched_prefixes) > 0:
49+
message = (
50+
f"{method_name} is deprecated. For more info, go to "
51+
"https://api.slack.com/changelog/2023-08-workflow-steps-from-apps-step-back"
52+
)
53+
warnings.warn(message)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import unittest
2+
import pytest
3+
4+
from slack_sdk.web import WebClient
5+
from tests.helpers import remove_os_env_temporarily, restore_os_env
6+
from tests.slack_sdk.web.mock_web_api_server import (
7+
setup_mock_web_api_server,
8+
cleanup_mock_web_api_server,
9+
)
10+
11+
12+
class TestWebClient(unittest.TestCase):
13+
def setUp(self):
14+
setup_mock_web_api_server(self)
15+
self.env_values = remove_os_env_temporarily()
16+
17+
def tearDown(self):
18+
cleanup_mock_web_api_server(self)
19+
restore_os_env(self.env_values)
20+
21+
# You can enable this test to verify if the warning can be printed as expected
22+
@pytest.mark.skip()
23+
def test_workflow_step_completed_deprecation(self):
24+
client = WebClient(base_url="http://localhost:8888")
25+
client.workflows_stepCompleted(token="xoxb-api_test", workflow_step_execute_id="W1234")
26+
27+
@pytest.mark.skip()
28+
def test_workflow_step_failed_deprecation(self):
29+
client = WebClient(base_url="http://localhost:8888")
30+
client.workflows_stepFailed(token="xoxb-api_test", workflow_step_execute_id="W1234", error={})
31+
32+
@pytest.mark.skip()
33+
def test_workflow_update_step_deprecation(self):
34+
client = WebClient(base_url="http://localhost:8888")
35+
client.workflows_updateStep(token="xoxb-api_test", workflow_step_edit_id="W1234", inputs={}, outputs={})

0 commit comments

Comments
 (0)