forked from slackapi/bolt-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_say.py
More file actions
42 lines (34 loc) · 1.29 KB
/
test_say.py
File metadata and controls
42 lines (34 loc) · 1.29 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
import pytest
from slack_sdk import WebClient
from slack_sdk.web import SlackResponse
from slack_bolt import Say
from tests.mock_web_api_server import (
setup_mock_web_api_server,
cleanup_mock_web_api_server,
)
class TestSay:
def setup_method(self):
setup_mock_web_api_server(self)
valid_token = "xoxb-valid"
mock_api_server_base_url = "http://localhost:8888"
self.web_client = WebClient(
token=valid_token, base_url=mock_api_server_base_url
)
def teardown_method(self):
cleanup_mock_web_api_server(self)
def test_say(self):
say = Say(client=self.web_client, channel="C111")
response: SlackResponse = say(text="Hi there!")
assert response.status_code == 200
def test_say_dict(self):
say = Say(client=self.web_client, channel="C111")
response: SlackResponse = say({"text": "Hi!"})
assert response.status_code == 200
def test_say_dict_channel(self):
say = Say(client=self.web_client, channel="C111")
response: SlackResponse = say({"text": "Hi!", "channel": "C111"})
assert response.status_code == 200
def test_say_invalid(self):
say = Say(client=self.web_client, channel="C111")
with pytest.raises(ValueError):
say([])