-
Notifications
You must be signed in to change notification settings - Fork 856
feat: support markdown_text parameter #1718
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
Changes from 2 commits
793b1cd
8341b6f
462ef6f
f00fa90
8f3fc22
4fb424a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -247,10 +247,12 @@ def _to_0_or_1_if_bool(v: Any) -> Union[Any, str]: | |
| return v | ||
|
|
||
|
|
||
| def _warn_if_text_or_attachment_fallback_is_missing(endpoint: str, kwargs: Dict[str, Any]) -> None: | ||
| def _warn_if_message_text_content_is_missing(endpoint: str, kwargs: Dict[str, Any]) -> None: | ||
| text = kwargs.get("text") | ||
| if text and len(text.strip()) > 0: | ||
| markdown_text = kwargs.get("markdown_text") | ||
| if (text and len(text.strip()) > 0) or (markdown_text and len(markdown_text.strip()) > 0): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion(non-blocking): Separating these cases as separate
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yess I agree let me see how this looks 💯 |
||
| # If a top-level text arg is provided, we are good. This is the recommended accessibility field to always provide. | ||
| # If a top-level markdown_text arg is provided, we are good. It should not be used in conjunction with text. | ||
| return | ||
|
|
||
| # for unit tests etc. | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question(non-blocking): Do we want to keep the issue_### pattern or can we change this to something like:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point let me rename this 💯 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import unittest | ||
| import warnings | ||
|
|
||
| from slack import WebClient | ||
| from tests.web.mock_web_api_handler import MockHandler | ||
|
|
@@ -11,6 +12,7 @@ def setUp(self): | |
|
|
||
| def tearDown(self): | ||
| cleanup_mock_web_api_server(self) | ||
| warnings.resetwarnings() | ||
|
|
||
| def test_missing_text_warning_chat_postMessage(self): | ||
| client = WebClient(base_url="http://localhost:8888", token="xoxb-api_test") | ||
|
|
@@ -65,3 +67,39 @@ def test_missing_fallback_warning_chat_update(self): | |
| with self.assertWarnsRegex(UserWarning, "`fallback` argument is missing"): | ||
| resp = client.chat_update(channel="C111", ts="111.222", blocks=[], attachments=[{"text": "hi"}]) | ||
| self.assertIsNone(resp["error"]) | ||
|
|
||
| def test_no_warning_when_markdown_text_is_provided_chat_postMessage(self): | ||
| client = WebClient(base_url="http://localhost:8888", token="xoxb-api_test") | ||
| with warnings.catch_warnings(record=True) as warning_list: | ||
| warnings.simplefilter("always") | ||
| resp = client.chat_postMessage(channel="C111", markdown_text="# hello") | ||
|
|
||
| self.assertEqual(warning_list, []) | ||
| self.assertIsNone(resp["error"]) | ||
|
Comment on lines
+77
to
+78
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🪄 ✨ |
||
|
|
||
| def test_no_warning_when_markdown_text_is_provided_chat_postEphemeral(self): | ||
| client = WebClient(base_url="http://localhost:8888", token="xoxb-api_test") | ||
| with warnings.catch_warnings(record=True) as warning_list: | ||
| warnings.simplefilter("always") | ||
| resp = client.chat_postEphemeral(channel="C111", user="U111", markdown_text="# hello") | ||
|
|
||
| self.assertEqual(warning_list, []) | ||
| self.assertIsNone(resp["error"]) | ||
|
|
||
| def test_no_warning_when_markdown_text_is_provided_chat_scheduleMessage(self): | ||
| client = WebClient(base_url="http://localhost:8888", token="xoxb-api_test") | ||
| with warnings.catch_warnings(record=True) as warning_list: | ||
| warnings.simplefilter("always") | ||
| resp = client.chat_scheduleMessage(channel="C111", post_at="299876400", markdown_text="# hello") | ||
|
|
||
| self.assertEqual(warning_list, []) | ||
| self.assertIsNone(resp["error"]) | ||
|
|
||
| def test_no_warning_when_markdown_text_is_provided_chat_update(self): | ||
| client = WebClient(base_url="http://localhost:8888", token="xoxb-api_test") | ||
| with warnings.catch_warnings(record=True) as warning_list: | ||
| warnings.simplefilter("always") | ||
| resp = client.chat_update(channel="C111", ts="111.222", markdown_text="# hello") | ||
|
|
||
| self.assertEqual(warning_list, []) | ||
| self.assertIsNone(resp["error"]) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: Adding this I think is a nice improvement for the typeahead hints found in some editors with virtual environments!
thought: It's nice to know that missing arguments aren't blocking new features though 🤖 ✨