Skip to content

Commit 347093a

Browse files
committed
add slackclient tests
1 parent 83df48c commit 347093a

4 files changed

Lines changed: 51 additions & 0 deletions

File tree

_pytest/conftest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
import pytest
22
from slackclient._channel import Channel
33
from slackclient._server import Server
4+
from slackclient._client import SlackClient
45

56
@pytest.fixture
67
def server(monkeypatch):
78
myserver = Server('xoxp-1234123412341234-12341234-1234', False)
89
return myserver
910

11+
@pytest.fixture
12+
def slackclient(server):
13+
myslackclient = SlackClient('xoxp-1234123412341234-12341234-1234')
14+
return myslackclient
15+
1016
@pytest.fixture
1117
def channel(server):
1218
mychannel = Channel(server, "somechannel", "C12341234", ["user"])
1319
return mychannel
20+

_pytest/data/channel.created.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "channel_created",
3+
"channel": {
4+
"id": "C024BE91L",
5+
"name": "fun",
6+
"created": 1360782804,
7+
"creator": "U024BE7LH"
8+
}
9+
}

_pytest/data/im.created.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "im_created",
3+
"user": "U024BE7LH",
4+
"channel": {
5+
"id": "D024BE91L",
6+
"user": "U123BL234",
7+
"created": 1360782804
8+
}
9+
}

_pytest/test_slackclient.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from slackclient._client import SlackClient
2+
from slackclient._channel import Channel
3+
import json
4+
import pytest
5+
6+
@pytest.fixture
7+
def channel_created():
8+
channel_created = open('_pytest/data/channel.created.json', 'r').read()
9+
channel_created = json.loads(channel_created)
10+
return channel_created
11+
12+
@pytest.fixture
13+
def im_created():
14+
channel_created = open('_pytest/data/im.created.json', 'r').read()
15+
channel_created = json.loads(channel_created)
16+
return channel_created
17+
18+
def test_SlackClient(slackclient):
19+
assert type(slackclient) == SlackClient
20+
21+
def test_SlackClient_process_changes(slackclient, channel_created, im_created):
22+
slackclient.process_changes(channel_created)
23+
assert type(slackclient.server.channels.find('fun')) == Channel
24+
slackclient.process_changes(im_created)
25+
assert type(slackclient.server.channels.find('U123BL234')) == Channel
26+

0 commit comments

Comments
 (0)