aboutsummaryrefslogtreecommitdiffstats
path: root/_pytest/conftest.py
diff options
context:
space:
mode:
Diffstat (limited to '_pytest/conftest.py')
-rw-r--r--_pytest/conftest.py84
1 files changed, 84 insertions, 0 deletions
diff --git a/_pytest/conftest.py b/_pytest/conftest.py
new file mode 100644
index 0000000..0212601
--- /dev/null
+++ b/_pytest/conftest.py
@@ -0,0 +1,84 @@
+import pickle
+import json
+import pytest
+import sys
+
+sys.path.append(".")
+
+#New stuff
+from wee_slack import EventRouter
+from wee_slack import SlackRequest
+import wee_slack
+
+class fakewebsocket(object):
+ def __init__(self):
+ self.returndata = []
+ pass
+ def add(self, data):
+ self.returndata.append(data)
+ def recv(self):
+ return json.dumps(self.returndata.pop(0))
+ def send(self, data):
+ print "websocket received: {}".format(data)
+ return
+
+@pytest.fixture
+def mock_websocket():
+ return fakewebsocket()
+
+@pytest.fixture
+def realish_eventrouter():
+ e = EventRouter()
+ pickled_data = pickle.dumps(SlackRequest('xoxoxoxox', "rtm.start", {"meh": "blah"}))
+ rtmstartdata = open('_pytest/data/http/rtm.start.json', 'r').read()
+ e.receive_httprequest_callback(pickled_data, 1, 0, rtmstartdata, 4)
+ e.handle_next()
+ return e
+
+
+class FakeWeechat():
+ """
+ this is the thing that acts as "w." everywhere..
+ basically mock out all of the weechat calls here i guess
+ """
+ WEECHAT_RC_OK = True
+
+ def __init__(self):
+ pass
+ #print "INITIALIZE FAKE WEECHAT"
+ def prnt(*args):
+ output = "("
+ for arg in args:
+ if arg != None:
+ output += "{}, ".format(arg)
+ print "w.prnt {}".format(output)
+ def hdata_get(*args):
+ return "0x000001"
+ def hdata_pointer(*args):
+ return "0x000002"
+ def hdata_time(*args):
+ return "1355517519"
+ def hdata_string(*args):
+ return "testuser"
+ def buffer_new(*args):
+ return "0x8a8a8a8b"
+
+ def __getattr__(self, name):
+ def method(*args):
+ pass
+ #print "called {}".format(name)
+ #if args:
+ # print "\twith args: {}".format(args)
+ return method
+
+@pytest.fixture
+def mock_weechat():
+ wee_slack.w = FakeWeechat()
+ wee_slack.config = wee_slack.PluginConfig()
+ wee_slack.debug_string = None
+ wee_slack.slack_debug = "debug_buffer_ptr"
+ wee_slack.STOP_TALKING_TO_SLACK = False
+ wee_slack.proc = {}
+ pass
+
+