diff options
author | Ryan Huber <rhuber@gmail.com> | 2017-04-12 16:47:43 +0000 |
---|---|---|
committer | Ryan Huber <rhuber@gmail.com> | 2017-04-12 16:47:43 +0000 |
commit | 95fa084893660b655388604084f082a080f1ba32 (patch) | |
tree | 8c667c21f591572052f6b3a046c1b94712285c40 /_pytest/test_process_message.py | |
parent | 01beb42fec5c6dbfc0d8c53ce1de88b48b48f6db (diff) | |
download | wee-slack-95fa084893660b655388604084f082a080f1ba32.tar.gz |
massssssssive merge of the new codebase
Diffstat (limited to '_pytest/test_process_message.py')
-rw-r--r-- | _pytest/test_process_message.py | 68 |
1 files changed, 39 insertions, 29 deletions
diff --git a/_pytest/test_process_message.py b/_pytest/test_process_message.py index 0ca56cd..e2447f7 100644 --- a/_pytest/test_process_message.py +++ b/_pytest/test_process_message.py @@ -1,38 +1,48 @@ - -import wee_slack -import pytest import json -from collections import defaultdict +from wee_slack import render + +def test_process_message(monkeypatch, realish_eventrouter, mock_websocket): -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 - wee_slack.unfurl_ignore_alt_text = False + e = realish_eventrouter - def mock_buffer_prnt(*args): - called['buffer_prnt'] += 1 - monkeypatch.setattr(wee_slack.Channel, 'buffer_prnt', mock_buffer_prnt) + t = e.teams.keys()[0] + u = e.teams[t].users.keys()[0] -# 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) + user = e.teams[t].users[u] + #print user + socket = mock_websocket + e.teams[t].ws = socket 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()) ) + messages.append(json.loads(open('_pytest/data/websocket/1485975421.33-message.json', 'r').read())) + + # test message and then change + messages.append(json.loads(open('_pytest/data/websocket/1485976157.18-message.json', 'r').read())) + messages.append(json.loads(open('_pytest/data/websocket/1485976151.6-message.json', 'r').read())) + + # test message then deletion + messages.append(json.loads(open('_pytest/data/websocket/1485975698.45-message.json', 'r').read())) + messages.append(json.loads(open('_pytest/data/websocket/1485975723.85-message.json', 'r').read())) + for m in messages: - wee_slack.process_message(m) - print "---" - print called - print "---" -# assert called['buffer_prnt'] == 2 -# assert called['buffer_prnt_changed'] == 1 + m["user"] = user.id + socket.add(m) + + e.receive_ws_callback(t) + e.handle_next() + + e.receive_ws_callback(t) + e.handle_next() + + e.receive_ws_callback(t) + e.handle_next() + + e.receive_ws_callback(t) + e.handle_next() + + + #assert e.teams[t].channels['C407ABS94'].messages.keys()[0] == '1485976151.00016' + #assert False + |