aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_cmdline.py10
-rw-r--r--test/test_language_websocket.py4
-rw-r--r--test/test_log.py22
-rw-r--r--test/test_pathod.py9
-rw-r--r--test/tutils.py2
5 files changed, 47 insertions, 0 deletions
diff --git a/test/test_cmdline.py b/test/test_cmdline.py
index 5a9ee242..b9607029 100644
--- a/test/test_cmdline.py
+++ b/test/test_cmdline.py
@@ -137,6 +137,16 @@ def test_pathoc(perror):
)
assert len(a.requests) == 1
+ a = cmdline.args_pathod(
+ [
+ "pathod",
+ "-c",
+ "?"
+ ]
+ )
+ assert perror.called
+ perror.reset_mock()
+
tutils.raises(
SystemExit,
cmdline.args_pathoc,
diff --git a/test/test_language_websocket.py b/test/test_language_websocket.py
index 70a626e6..f75562c9 100644
--- a/test/test_language_websocket.py
+++ b/test/test_language_websocket.py
@@ -45,6 +45,10 @@ class TestWebsocketFrame:
]
self._test_messages(specs, websockets.WebsocketClientFrame)
+ def test_nested_frame(self):
+ wf = parse_request("wf:f'wf'")
+ assert wf.nested_frame
+
def test_flags(self):
wf = parse_request("wf:fin:mask:rsv1:rsv2:rsv3")
frm = netlib.websockets.Frame.from_bytes(tutils.render(wf))
diff --git a/test/test_log.py b/test/test_log.py
new file mode 100644
index 00000000..5473236e
--- /dev/null
+++ b/test/test_log.py
@@ -0,0 +1,22 @@
+import StringIO
+from libpathod import log
+import netlib.tcp
+
+
+class DummyIO(StringIO.StringIO):
+ def start_log(self, *args, **kwargs):
+ pass
+
+ def get_log(self, *args, **kwargs):
+ return ""
+
+
+def test_disconnect():
+ outf = DummyIO()
+ rw = DummyIO()
+ try:
+ with log.Log(outf, False, rw, rw) as lg:
+ raise netlib.tcp.NetLibDisconnect()
+ except netlib.tcp.NetLibDisconnect:
+ pass
+ assert "Disconnected" in outf.getvalue()
diff --git a/test/test_pathod.py b/test/test_pathod.py
index 2adcae40..f27f4d38 100644
--- a/test/test_pathod.py
+++ b/test/test_pathod.py
@@ -109,6 +109,15 @@ class TestHexdump(tutils.DaemonTests):
r = self.get(r"200:b'\xf0'")
+class TestNocraft(tutils.DaemonTests):
+ nocraft = True
+
+ def test_nocraft(self):
+ r = self.get(r"200:b'\xf0'")
+ assert r.status_code == 800
+ assert "Crafting disabled" in r.content
+
+
class CommonTests(tutils.DaemonTests):
def test_binarydata(self):
r = self.get(r"200:b'\xf0'")
diff --git a/test/tutils.py b/test/tutils.py
index 778ad790..dc118bbe 100644
--- a/test/tutils.py
+++ b/test/tutils.py
@@ -16,6 +16,7 @@ class DaemonTests(object):
timeout = None
hexdump = False
ssloptions = None
+ nocraft = False
@classmethod
def setUpAll(klass):
@@ -36,6 +37,7 @@ class DaemonTests(object):
nohang = klass.nohang,
timeout = klass.timeout,
hexdump = klass.hexdump,
+ nocraft = klass.nocraft,
logreq = True,
logresp = True,
explain = True