diff options
-rw-r--r-- | _pytest/conftest.py | 7 | ||||
-rw-r--r-- | _pytest/test_presencechange.py | 3 | ||||
-rw-r--r-- | _pytest/test_process_message.py | 8 |
3 files changed, 7 insertions, 11 deletions
diff --git a/_pytest/conftest.py b/_pytest/conftest.py index 043b125..0a770c7 100644 --- a/_pytest/conftest.py +++ b/_pytest/conftest.py @@ -3,6 +3,7 @@ from __future__ import print_function, unicode_literals import json import pytest import random +import ssl import string import sys @@ -22,7 +23,10 @@ class fakewebsocket(object): def recv(self): return self.recv_data()[1].decode('utf-8') def recv_data(self, control_frame=False): - return ABNF.OPCODE_TEXT, self.returndata.pop(0) + if self.returndata: + return ABNF.OPCODE_TEXT, self.returndata.pop(0) + else: + raise ssl.SSLWantReadError() def send(self, data): self.sentdata.append(data) @@ -33,6 +37,7 @@ def mock_websocket(): @pytest.fixture def realish_eventrouter(mock_websocket, mock_weechat): e = EventRouter() + wee_slack.EVENTROUTER = e context = e.store_context(SlackRequest('xoxs-token', 'rtm.start', {})) with open('_pytest/data/http/rtm.start.json') as rtmstartfile: if sys.version_info.major == 2: diff --git a/_pytest/test_presencechange.py b/_pytest/test_presencechange.py index 3dee5c3..a6e9eb6 100644 --- a/_pytest/test_presencechange.py +++ b/_pytest/test_presencechange.py @@ -12,11 +12,10 @@ def test_PresenceChange(realish_eventrouter, team, user_alice): "user": user_alice.identifier, "presence": "away", }) - realish_eventrouter.receive_ws_callback(team.team_hash) + realish_eventrouter.handle_next() assert user_alice.presence == "active" - realish_eventrouter.receive_ws_callback(team.team_hash) realish_eventrouter.handle_next() assert user_alice.presence == "away" diff --git a/_pytest/test_process_message.py b/_pytest/test_process_message.py index 6209cdf..225b971 100644 --- a/_pytest/test_process_message.py +++ b/_pytest/test_process_message.py @@ -23,17 +23,9 @@ def test_process_message(realish_eventrouter, team, user_alice): realish_eventrouter.receive_ws_callback(team.team_hash) realish_eventrouter.handle_next() - - realish_eventrouter.receive_ws_callback(team.team_hash) realish_eventrouter.handle_next() - - realish_eventrouter.receive_ws_callback(team.team_hash) realish_eventrouter.handle_next() - - realish_eventrouter.receive_ws_callback(team.team_hash) realish_eventrouter.handle_next() - - realish_eventrouter.receive_ws_callback(team.team_hash) realish_eventrouter.handle_next() assert sum([len(channel.messages) for channel in team.channels.values()]) == 3 |