Skip to content

Commit

Permalink
add slackclient tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rawdigits committed Mar 11, 2015
1 parent 83df48c commit 347093a
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
7 changes: 7 additions & 0 deletions _pytest/conftest.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import pytest
from slackclient._channel import Channel
from slackclient._server import Server
from slackclient._client import SlackClient

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

@pytest.fixture
def slackclient(server):
myslackclient = SlackClient('xoxp-1234123412341234-12341234-1234')
return myslackclient

@pytest.fixture
def channel(server):
mychannel = Channel(server, "somechannel", "C12341234", ["user"])
return mychannel

9 changes: 9 additions & 0 deletions _pytest/data/channel.created.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "channel_created",
"channel": {
"id": "C024BE91L",
"name": "fun",
"created": 1360782804,
"creator": "U024BE7LH"
}
}
9 changes: 9 additions & 0 deletions _pytest/data/im.created.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "im_created",
"user": "U024BE7LH",
"channel": {
"id": "D024BE91L",
"user": "U123BL234",
"created": 1360782804
}
}
26 changes: 26 additions & 0 deletions _pytest/test_slackclient.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from slackclient._client import SlackClient
from slackclient._channel import Channel
import json
import pytest

@pytest.fixture
def channel_created():
channel_created = open('_pytest/data/channel.created.json', 'r').read()
channel_created = json.loads(channel_created)
return channel_created

@pytest.fixture
def im_created():
channel_created = open('_pytest/data/im.created.json', 'r').read()
channel_created = json.loads(channel_created)
return channel_created

def test_SlackClient(slackclient):
assert type(slackclient) == SlackClient

def test_SlackClient_process_changes(slackclient, channel_created, im_created):
slackclient.process_changes(channel_created)
assert type(slackclient.server.channels.find('fun')) == Channel
slackclient.process_changes(im_created)
assert type(slackclient.server.channels.find('U123BL234')) == Channel

0 comments on commit 347093a

Please sign in to comment.