forked from slackapi/python-slack-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_slackclient.py
More file actions
53 lines (36 loc) · 1.72 KB
/
Copy pathtest_slackclient.py
File metadata and controls
53 lines (36 loc) · 1.72 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
import json
import pytest
from requests.exceptions import ProxyError
from slackclient.channel import Channel
from slackclient.client import SlackClient
from slackclient.server import SlackConnectionError
@pytest.fixture
def channel_created_fixture():
file_channel_created_data = open('tests/data/channel.created.json', 'r').read()
json_channel_created_data = json.loads(file_channel_created_data)
return json_channel_created_data
@pytest.fixture
def im_created_fixture():
file_channel_created_data = open('tests/data/im.created.json', 'r').read()
json_channel_created_data = json.loads(file_channel_created_data)
return json_channel_created_data
def test_proxy():
proxies = {'http': 'some-bad-proxy', 'https': 'some-bad-proxy'}
client = SlackClient('xoxp-1234123412341234-12341234-1234', proxies=proxies)
server = client.server
assert server.proxies == proxies
with pytest.raises(ProxyError):
server.rtm_connect()
with pytest.raises(SlackConnectionError):
server.connect_slack_websocket('wss://mpmulti-xw58.slack-msgs.com/websocket/bad-token')
api_requester = server.api_requester
assert api_requester.proxies == proxies
with pytest.raises(ProxyError):
api_requester.do('xoxp-1234123412341234-12341234-1234', request='channels.list')
def test_SlackClient(slackclient):
assert type(slackclient) == SlackClient
def test_SlackClient_process_changes(slackclient, channel_created_fixture, im_created_fixture):
slackclient.process_changes(channel_created_fixture)
assert type(slackclient.server.channels.find('fun')) == Channel
slackclient.process_changes(im_created_fixture)
assert type(slackclient.server.channels.find('U123BL234')) == Channel