-
Notifications
You must be signed in to change notification settings - Fork 856
Expand file tree
/
Copy pathtest_web_client_issue_891.py
More file actions
105 lines (85 loc) · 5.17 KB
/
test_web_client_issue_891.py
File metadata and controls
105 lines (85 loc) · 5.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import unittest
import warnings
from slack import WebClient
from tests.web.mock_web_api_handler import MockHandler
from tests.mock_web_api_server import setup_mock_web_api_server, cleanup_mock_web_api_server
class TestWebClient_Issue_891(unittest.TestCase):
def setUp(self):
setup_mock_web_api_server(self, MockHandler)
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")
with self.assertWarnsRegex(UserWarning, "`text` argument is missing"):
resp = client.chat_postMessage(channel="C111", blocks=[])
self.assertIsNone(resp["error"])
def test_missing_text_warning_chat_postEphemeral(self):
client = WebClient(base_url="http://localhost:8888", token="xoxb-api_test")
with self.assertWarnsRegex(UserWarning, "`text` argument is missing"):
resp = client.chat_postEphemeral(channel="C111", user="U111", blocks=[])
self.assertIsNone(resp["error"])
def test_missing_text_warning_chat_scheduleMessage(self):
client = WebClient(base_url="http://localhost:8888", token="xoxb-api_test")
with self.assertWarnsRegex(UserWarning, "`text` argument is missing"):
resp = client.chat_scheduleMessage(channel="C111", post_at="299876400", text="", blocks=[])
self.assertIsNone(resp["error"])
def test_missing_text_warning_chat_update(self):
client = WebClient(base_url="http://localhost:8888", token="xoxb-api_test")
with self.assertWarnsRegex(UserWarning, "`text` argument is missing"):
resp = client.chat_update(channel="C111", ts="111.222", blocks=[])
self.assertIsNone(resp["error"])
def test_missing_fallback_warning_chat_postMessage(self):
client = WebClient(base_url="http://localhost:8888", token="xoxb-api_test")
with self.assertWarnsRegex(UserWarning, "`fallback` argument is missing"):
resp = client.chat_postMessage(channel="C111", blocks=[], attachments=[{"text": "hi"}])
self.assertIsNone(resp["error"])
def test_missing_fallback_warning_chat_postEphemeral(self):
client = WebClient(base_url="http://localhost:8888", token="xoxb-api_test")
with self.assertWarnsRegex(UserWarning, "`fallback` argument is missing"):
resp = client.chat_postEphemeral(channel="C111", user="U111", blocks=[], attachments=[{"text": "hi"}])
self.assertIsNone(resp["error"])
def test_missing_fallback_warning_chat_scheduleMessage(self):
client = WebClient(base_url="http://localhost:8888", token="xoxb-api_test")
with self.assertWarnsRegex(UserWarning, "`fallback` argument is missing"):
resp = client.chat_scheduleMessage(
channel="C111",
post_at="299876400",
text="",
blocks=[],
attachments=[{"text": "hi"}],
)
self.assertIsNone(resp["error"])
def test_missing_fallback_warning_chat_update(self):
client = WebClient(base_url="http://localhost:8888", token="xoxb-api_test")
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"])
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"])