diff options
author | Ryan Huber <rhuber@gmail.com> | 2017-02-08 08:43:48 -0800 |
---|---|---|
committer | Ryan Huber <rhuber@gmail.com> | 2017-02-08 08:43:48 -0800 |
commit | e411a9d01e1c6e67c2ad413342b0e52efab0d5ca (patch) | |
tree | 5f551644db95d94eacf277813143bf36c93106dc | |
parent | 9ba8a72431f961dbfa210c082a7f75cd0239f543 (diff) | |
download | wee-slack-e411a9d01e1c6e67c2ad413342b0e52efab0d5ca.tar.gz |
team join fixed + test
-rw-r--r-- | _pytest/test_everything.py | 2 | ||||
-rw-r--r-- | _pytest/test_processteamjoin.py | 54 | ||||
-rw-r--r-- | wee_slack.py | 13 |
3 files changed, 66 insertions, 3 deletions
diff --git a/_pytest/test_everything.py b/_pytest/test_everything.py index 1abfa42..a121541 100644 --- a/_pytest/test_everything.py +++ b/_pytest/test_everything.py @@ -44,7 +44,7 @@ def test_process_message(monkeypatch, realish_eventrouter, mock_websocket): print "####################" print len(eventrouter.queue) -# assert False + #assert False diff --git a/_pytest/test_processteamjoin.py b/_pytest/test_processteamjoin.py new file mode 100644 index 0000000..00a8b4c --- /dev/null +++ b/_pytest/test_processteamjoin.py @@ -0,0 +1,54 @@ +import glob +import json + +from wee_slack import ProcessNotImplemented + +def test_process_reply(monkeypatch, mock_websocket, realish_eventrouter): + + eventrouter = realish_eventrouter + + t = eventrouter.teams.keys()[0] + #u = eventrouter.teams[t].users.keys()[0] + + #user = eventrouter.teams[t].users[u] + #print user + + #delete charles so we can add him + del eventrouter.teams[t].users['U4096CBHC'] + + assert len(eventrouter.teams[t].users) == 3 + + socket = mock_websocket + eventrouter.teams[t].ws = socket + + datafiles = glob.glob("_pytest/data/websocket/1485975606.59-team_join.json") + + print datafiles + #assert False + + notimplemented = set() + + for fname in datafiles: + try: + print "####################" + data = json.loads(open(fname, 'r').read()) + socket.add(data) + print data + eventrouter.receive_ws_callback(t) + eventrouter.handle_next() + except ProcessNotImplemented as e: + notimplemented.add(str(e)) + #this handles some message data not existing - need to fix + except KeyError: + pass + + if len(notimplemented) > 0: + print "####################" + print sorted(notimplemented) + print "####################" + + #print len(eventrouter.queue) + assert len(eventrouter.teams[t].users) == 4 + + + diff --git a/wee_slack.py b/wee_slack.py index 3caa868..0ee162b 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -1804,6 +1804,11 @@ def process_user_typing(message_json, eventrouter, **kwargs): channel.set_typing(team.users.get(message_json["user"]).name) w.bar_item_update("slack_typing_notice") +def process_team_join(message_json, eventrouter, **kwargs): + user = message_json['user'] + team = kwargs["team"] + team.users[user["id"]] = SlackUser(**user) + def process_pong(message_json, eventrouter, **kwargs): pass @@ -2434,9 +2439,13 @@ def command_mute(current_buffer, args): EVENTROUTER.receive(s) def command_openweb(current_buffer, args): + #if done from server buffer, open slack for reals channel = EVENTROUTER.weechat_controller.buffers[current_buffer] - now = SlackTS() - url = "https://{}/archives/{}/p{}000000".format(channel.team.domain, channel.slack_name, now.majorstr()) + if isinstance(channel, SlackTeam): + url = "https://{}".format(channel.team.domain) + else: + now = SlackTS() + url = "https://{}/archives/{}/p{}000000".format(channel.team.domain, channel.slack_name, now.majorstr()) w.prnt_date_tags(channel.team.channel_buffer, SlackTS().major, "openweb,logger_backlog_end,notify_none", url) def command_nodistractions(current_buffer, args): |