aboutsummaryrefslogtreecommitdiffstats
path: root/_pytest/test_process_message.py
diff options
context:
space:
mode:
authorRyan Huber <rhuber@gmail.com>2015-03-18 23:33:16 -0700
committerRyan Huber <rhuber@gmail.com>2015-03-18 23:33:16 -0700
commit376db5991158c3c20a944f011433352c6d596dbe (patch)
tree91129f15ee405c9f79ff96802ab606c89a59ec22 /_pytest/test_process_message.py
parentb522ae2870d30b91db5f81c77e99f4dd31883f86 (diff)
downloadwee-slack-376db5991158c3c20a944f011433352c6d596dbe.tar.gz
add some initial tests. messages need a lot of work..
Diffstat (limited to '_pytest/test_process_message.py')
-rw-r--r--_pytest/test_process_message.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/_pytest/test_process_message.py b/_pytest/test_process_message.py
new file mode 100644
index 0000000..6c58336
--- /dev/null
+++ b/_pytest/test_process_message.py
@@ -0,0 +1,40 @@
+
+import wee_slack
+import pytest
+import json
+from collections import defaultdict
+
+
+def test_process_message(slack_debug, monkeypatch, myservers, mychannels, myusers):
+ called = defaultdict(int)
+ wee_slack.servers = myservers
+ wee_slack.channels = mychannels
+ wee_slack.users = myusers
+ wee_slack.message_cache = {}
+ wee_slack.servers[0].users = myusers
+
+ def mock_buffer_prnt(*args):
+ called['buffer_prnt'] += 1
+ monkeypatch.setattr(wee_slack.Channel, 'buffer_prnt', mock_buffer_prnt)
+
+# def mock_buffer_prnt_changed(*args):
+# called['buffer_prnt_changed'] += 1
+# print args
+# monkeypatch.setattr(wee_slack.Channel, 'buffer_prnt_changed', mock_buffer_prnt_changed)
+
+
+ messages = []
+ messages.append( json.loads(open('_pytest/data/message-normal.json', 'r').read()) )
+ messages.append( json.loads(open('_pytest/data/message-normal2.json', 'r').read()) )
+ messages.append( json.loads(open('_pytest/data/message-changed.json', 'r').read()) )
+ messages.append( json.loads(open('_pytest/data/message-deleted.json', 'r').read()) )
+ for m in messages:
+ wee_slack.process_message(m)
+ print called
+# assert called['buffer_prnt'] == 2
+# assert called['buffer_prnt_changed'] == 1
+
+
+
+
+