Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add deprecation warnings to Steps from Apps methods #1504

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions slack_sdk/web/deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down Expand Up @@ -40,3 +42,12 @@
"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 = (

Check warning on line 49 in slack_sdk/web/deprecation.py

View check run for this annotation

Codecov / codecov/patch

slack_sdk/web/deprecation.py#L47-L49

Added lines #L47 - L49 were not covered by tests
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)

Check warning on line 53 in slack_sdk/web/deprecation.py

View check run for this annotation

Codecov / codecov/patch

slack_sdk/web/deprecation.py#L53

Added line #L53 was not covered by tests
35 changes: 35 additions & 0 deletions tests/slack_sdk/web/test_web_client_workflow_step_deprecation.py
Original file line number Diff line number Diff line change
@@ -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={})
Loading