aboutsummaryrefslogtreecommitdiffstats
path: root/test/pathod/test_pathoc.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/pathod/test_pathoc.py')
-rw-r--r--test/pathod/test_pathoc.py57
1 files changed, 15 insertions, 42 deletions
diff --git a/test/pathod/test_pathoc.py b/test/pathod/test_pathoc.py
index 8b69a2a6..dc5011c0 100644
--- a/test/pathod/test_pathoc.py
+++ b/test/pathod/test_pathoc.py
@@ -17,43 +17,26 @@ def test_response():
class PathocTestDaemon(tutils.DaemonTests):
- def tval(
- self,
- requests,
- showreq=False,
- showresp=False,
- explain=False,
- showssl=False,
- hexdump=False,
- timeout=None,
- ignorecodes=(),
- ignoretimeout=None,
- showsummary=True
- ):
+ def tval(self, requests, timeout=None, showssl=False, **kwargs):
s = StringIO()
c = pathoc.Pathoc(
("127.0.0.1", self.d.port),
ssl=self.ssl,
- showreq=showreq,
- showresp=showresp,
- explain=explain,
- hexdump=hexdump,
- ignorecodes=ignorecodes,
- ignoretimeout=ignoretimeout,
- showsummary=showsummary,
- fp=s
+ fp=s,
+ **kwargs
)
with c.connect(showssl=showssl, fp=s):
if timeout:
c.settimeout(timeout)
for i in requests:
r = language.parse_pathoc(i).next()
- if explain:
+ if kwargs.get("explain"):
r = r.freeze(language.Settings())
try:
c.request(r)
except NetlibException:
pass
+ self.d.wait_for_silence()
return s.getvalue()
@@ -66,14 +49,10 @@ class TestDaemonSSL(PathocTestDaemon):
)
def test_sni(self):
- c = pathoc.Pathoc(
- ("127.0.0.1", self.d.port),
- ssl=True,
- sni="foobar.com",
- fp=None
+ self.tval(
+ ["get:/p/200"],
+ sni="foobar.com"
)
- with c.connect():
- c.request("get:/p/200")
log = self.d.log()
assert log[0]["request"]["sni"] == "foobar.com"
@@ -81,15 +60,10 @@ class TestDaemonSSL(PathocTestDaemon):
assert "certificate chain" in self.tval(["get:/p/200"], showssl=True)
def test_clientcert(self):
- c = pathoc.Pathoc(
- ("127.0.0.1", self.d.port),
- ssl=True,
+ self.tval(
+ ["get:/p/200"],
clientcert=tutils.test_data.path("data/clientcert/client.pem"),
- fp=None
)
- with c.connect():
- c.request("get:/p/200")
-
log = self.d.log()
assert log[0]["request"]["clientcert"]["keyinfo"]
@@ -170,9 +144,7 @@ class TestDaemon(PathocTestDaemon):
assert "Invalid server response" in self.tval(["get:'/p/200:d2'"])
def test_websocket_shutdown(self):
- c = pathoc.Pathoc(("127.0.0.1", self.d.port), fp=None)
- with c.connect():
- c.request("ws:/")
+ self.tval(["ws:/"])
def test_wait_finish(self):
c = pathoc.Pathoc(
@@ -182,9 +154,10 @@ class TestDaemon(PathocTestDaemon):
)
with c.connect():
c.request("ws:/")
- c.request("wf:f'wf:x100'")
- [i for i in c.wait(timeout=0, finish=False)]
- [i for i in c.wait(timeout=0)]
+ c.request("wf:f'wf'")
+ # This should read a frame and close the websocket reader
+ assert len([i for i in c.wait(timeout=5, finish=False)]) == 1
+ assert not [i for i in c.wait(timeout=0)]
def test_connect_fail(self):
to = ("foobar", 80)