Skip to content

Commit 462ef6f

Browse files
rename test file and improve tests coverage
1 parent 8341b6f commit 462ef6f

File tree

3 files changed

+81
-3
lines changed

3 files changed

+81
-3
lines changed

tests/slack_sdk/web/test_web_client_issue_891.py renamed to tests/slack_sdk/web/test_web_client_msg_text_content_warnings.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import unittest
2+
import warnings
23

34
from slack_sdk import WebClient
45
from tests.web.mock_web_api_handler import MockHandler
56
from tests.mock_web_api_server import setup_mock_web_api_server, cleanup_mock_web_api_server
67

78

8-
class TestWebClient_Issue_891(unittest.TestCase):
9+
class TestWebClientMessageTextContentWarnings(unittest.TestCase):
910
def setUp(self):
1011
setup_mock_web_api_server(self, MockHandler)
1112

@@ -65,3 +66,39 @@ def test_missing_fallback_warning_chat_update(self):
6566
with self.assertWarnsRegex(UserWarning, "`fallback` argument is missing"):
6667
resp = client.chat_update(channel="C111", ts="111.222", blocks=[], attachments=[{"text": "hi"}])
6768
self.assertIsNone(resp["error"])
69+
70+
def test_no_warning_when_markdown_text_is_provided_chat_postMessage(self):
71+
client = WebClient(base_url="http://localhost:8888", token="xoxb-api_test")
72+
with warnings.catch_warnings(record=True) as warning_list:
73+
warnings.simplefilter("always")
74+
resp = client.chat_postMessage(channel="C111", markdown_text="# hello")
75+
76+
self.assertEqual(warning_list, [])
77+
self.assertIsNone(resp["error"])
78+
79+
def test_no_warning_when_markdown_text_is_provided_chat_postEphemeral(self):
80+
client = WebClient(base_url="http://localhost:8888", token="xoxb-api_test")
81+
with warnings.catch_warnings(record=True) as warning_list:
82+
warnings.simplefilter("always")
83+
resp = client.chat_postEphemeral(channel="C111", user="U111", markdown_text="# hello")
84+
85+
self.assertEqual(warning_list, [])
86+
self.assertIsNone(resp["error"])
87+
88+
def test_no_warning_when_markdown_text_is_provided_chat_scheduleMessage(self):
89+
client = WebClient(base_url="http://localhost:8888", token="xoxb-api_test")
90+
with warnings.catch_warnings(record=True) as warning_list:
91+
warnings.simplefilter("always")
92+
resp = client.chat_scheduleMessage(channel="C111", post_at="299876400", markdown_text="# hello")
93+
94+
self.assertEqual(warning_list, [])
95+
self.assertIsNone(resp["error"])
96+
97+
def test_no_warning_when_markdown_text_is_provided_chat_update(self):
98+
client = WebClient(base_url="http://localhost:8888", token="xoxb-api_test")
99+
with warnings.catch_warnings(record=True) as warning_list:
100+
warnings.simplefilter("always")
101+
resp = client.chat_update(channel="C111", ts="111.222", markdown_text="# hello")
102+
103+
self.assertEqual(warning_list, [])
104+
self.assertIsNone(resp["error"])

tests/slack_sdk_async/web/test_web_client_issue_891.py renamed to tests/slack_sdk_async/web/test_web_client_msg_text_content_warnings.py

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import unittest
2+
import warnings
23

34
from slack_sdk.web.async_client import AsyncWebClient
45
from tests.helpers import async_test
56
from tests.slack_sdk.web.mock_web_api_handler import MockHandler
67
from tests.mock_web_api_server import setup_mock_web_api_server_async, cleanup_mock_web_api_server_async
78

89

9-
class TestWebClient_Issue_829(unittest.TestCase):
10+
class TestWebClientMessageTextContentWarnings(unittest.TestCase):
1011
def setUp(self):
1112
setup_mock_web_api_server_async(self, MockHandler)
1213

@@ -74,3 +75,43 @@ async def test_missing_fallback_warning_chat_update(self):
7475
with self.assertWarnsRegex(UserWarning, "`text` argument is missing"):
7576
resp = await client.chat_update(channel="C111", ts="111.222", blocks=[], attachments=[{"text": "hi"}])
7677
self.assertIsNone(resp["error"])
78+
79+
@async_test
80+
def test_no_warning_when_markdown_text_is_provided_chat_postMessage(self):
81+
client = WebClient(base_url="http://localhost:8888", token="xoxb-api_test")
82+
with warnings.catch_warnings(record=True) as warning_list:
83+
warnings.simplefilter("always")
84+
resp = client.chat_postMessage(channel="C111", markdown_text="# hello")
85+
86+
self.assertEqual(warning_list, [])
87+
self.assertIsNone(resp["error"])
88+
89+
@async_test
90+
def test_no_warning_when_markdown_text_is_provided_chat_postEphemeral(self):
91+
client = WebClient(base_url="http://localhost:8888", token="xoxb-api_test")
92+
with warnings.catch_warnings(record=True) as warning_list:
93+
warnings.simplefilter("always")
94+
resp = client.chat_postEphemeral(channel="C111", user="U111", markdown_text="# hello")
95+
96+
self.assertEqual(warning_list, [])
97+
self.assertIsNone(resp["error"])
98+
99+
@async_test
100+
def test_no_warning_when_markdown_text_is_provided_chat_scheduleMessage(self):
101+
client = WebClient(base_url="http://localhost:8888", token="xoxb-api_test")
102+
with warnings.catch_warnings(record=True) as warning_list:
103+
warnings.simplefilter("always")
104+
resp = client.chat_scheduleMessage(channel="C111", post_at="299876400", markdown_text="# hello")
105+
106+
self.assertEqual(warning_list, [])
107+
self.assertIsNone(resp["error"])
108+
109+
@async_test
110+
def test_no_warning_when_markdown_text_is_provided_chat_update(self):
111+
client = WebClient(base_url="http://localhost:8888", token="xoxb-api_test")
112+
with warnings.catch_warnings(record=True) as warning_list:
113+
warnings.simplefilter("always")
114+
resp = client.chat_update(channel="C111", ts="111.222", markdown_text="# hello")
115+
116+
self.assertEqual(warning_list, [])
117+
self.assertIsNone(resp["error"])

tests/web/test_web_client_issue_891.py renamed to tests/web/test_web_client_msg_text_content_warnings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from tests.mock_web_api_server import setup_mock_web_api_server, cleanup_mock_web_api_server
77

88

9-
class TestWebClient_Issue_891(unittest.TestCase):
9+
class TestWebClientMessageTextContentWarnings(unittest.TestCase):
1010
def setUp(self):
1111
setup_mock_web_api_server(self, MockHandler)
1212

0 commit comments

Comments
 (0)