def realish_eventrouter(mock_websocket, mock_weechat): e = EventRouter() 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: rtmstartdata = rtmstartfile.read().decode('utf-8') else: rtmstartdata = rtmstartfile.read() e.receive_httprequest_callback(context, '', 0, rtmstartdata, '') while len(e.queue): e.handle_next() for team in e.teams.values(): team.ws = mock_websocket return e
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: rtmstartdata = rtmstartfile.read().decode('utf-8') else: rtmstartdata = rtmstartfile.read() e.receive_httprequest_callback(context, '', 0, rtmstartdata, '') while len(e.queue): e.handle_next() for team in e.teams.values(): team.ws = mock_websocket return e
def realish_eventrouter(): e = EventRouter() context = e.store_context(SlackRequest('xoxoxoxox', "rtm.start", {"meh": "blah"})) rtmstartdata = open('_pytest/data/http/rtm.start.json', 'r').read() e.receive_httprequest_callback(context, 1, 0, rtmstartdata, 4) e.handle_next() #e.sc is just shortcuts to these items e.sc = {} e.sc["team_id"] = e.teams.keys()[0] e.sc["team"] = e.teams[e.sc["team_id"]] e.sc["user"] = e.teams[e.sc["team_id"]].users[e.teams[e.sc["team_id"]].users.keys()[0]] socket = mock_websocket e.teams[e.sc["team_id"]].ws = socket return e
def realish_eventrouter(mock_websocket, mock_weechat): e = EventRouter() wee_slack.EVENTROUTER = e context = e.store_context(initiate_connection("xoxs-token")) with open("_pytest/data/http/rtm.start.json") as rtmstartfile: if sys.version_info.major == 2: rtmstartdata = rtmstartfile.read().decode("utf-8") else: rtmstartdata = rtmstartfile.read() e.receive_httprequest_callback(context, "", 0, rtmstartdata, "") while len(e.queue): e.handle_next() for team in e.teams.values(): team.ws = mock_websocket return e
def test_EventRouterReceivedata(mock_weechat): e = EventRouter() context = e.store_context( SlackRequest('xoxoxoxox', "rtm.startold", {"meh": "blah"})) print context e.receive_httprequest_callback(context, 1, -1, ' {"JSON": "MEH", ', 4) #print len(e.reply_buffer) context = e.store_context( SlackRequest('xoxoxoxox', "rtm.startold", {"meh": "blah"})) print context e.receive_httprequest_callback(context, 1, -1, ' "JSON2": "MEH", ', 4) #print len(e.reply_buffer) context = e.store_context( SlackRequest('xoxoxoxox', "rtm.startold", {"meh": "blah"})) print context e.receive_httprequest_callback(context, 1, 0, ' "JSON3": "MEH"}', 4) #print len(e.reply_buffer) try: e.handle_next() e.handle_next() e.handle_next() e.handle_next() except: pass print e.context #assert False context = e.store_context( SlackRequest('xoxoxoxox', "rtm.start", {"meh": "blah"})) rtmstartdata = open('_pytest/data/http/rtm.start.json', 'r').read() e.receive_httprequest_callback(context, 1, -1, rtmstartdata[:5000], 4) e.receive_httprequest_callback(context, 1, 0, rtmstartdata[5000:], 4) e.handle_next() #print len(e.reply_buffer) #print e.teams for t in e.teams: #print vars(e.teams[t]) for c in e.teams[t].channels: pass #print c for u in e.teams[t].users: pass
def test_EventRouterReceivedata(mock_weechat): e = EventRouter() context = e.store_context(SlackRequest('xoxoxoxox', "rtm.startold", {"meh": "blah"})) print context e.receive_httprequest_callback(context, 1, -1, ' {"JSON": "MEH", ', 4) #print len(e.reply_buffer) context = e.store_context(SlackRequest('xoxoxoxox', "rtm.startold", {"meh": "blah"})) print context e.receive_httprequest_callback(context, 1, -1, ' "JSON2": "MEH", ', 4) #print len(e.reply_buffer) context = e.store_context(SlackRequest('xoxoxoxox', "rtm.startold", {"meh": "blah"})) print context e.receive_httprequest_callback(context, 1, 0, ' "JSON3": "MEH"}', 4) #print len(e.reply_buffer) try: e.handle_next() e.handle_next() e.handle_next() e.handle_next() except: pass print e.context #assert False context = e.store_context(SlackRequest('xoxoxoxox', "rtm.start", {"meh": "blah"})) rtmstartdata = open('_pytest/data/http/rtm.start.json', 'r').read() e.receive_httprequest_callback(context, 1, -1, rtmstartdata[:5000], 4) e.receive_httprequest_callback(context, 1, 0, rtmstartdata[5000:], 4) e.handle_next() #print len(e.reply_buffer) #print e.teams for t in e.teams: #print vars(e.teams[t]) for c in e.teams[t].channels: pass #print c for u in e.teams[t].users: pass