|
1 | 1 | import unittest |
| 2 | +import warnings |
2 | 3 |
|
3 | 4 | from slack_sdk.web.async_client import AsyncWebClient |
4 | 5 | from tests.helpers import async_test |
5 | 6 | from tests.slack_sdk.web.mock_web_api_handler import MockHandler |
6 | 7 | from tests.mock_web_api_server import setup_mock_web_api_server_async, cleanup_mock_web_api_server_async |
7 | 8 |
|
8 | 9 |
|
9 | | -class TestWebClient_Issue_829(unittest.TestCase): |
| 10 | +class TestWebClientMessageTextContentWarnings(unittest.TestCase): |
10 | 11 | def setUp(self): |
11 | 12 | setup_mock_web_api_server_async(self, MockHandler) |
12 | 13 |
|
@@ -74,3 +75,43 @@ async def test_missing_fallback_warning_chat_update(self): |
74 | 75 | with self.assertWarnsRegex(UserWarning, "`text` argument is missing"): |
75 | 76 | resp = await client.chat_update(channel="C111", ts="111.222", blocks=[], attachments=[{"text": "hi"}]) |
76 | 77 | 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"]) |
0 commit comments