diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test_app.py | 24 | ||||
-rw-r--r-- | test/test_pathoc.py | 6 | ||||
-rw-r--r-- | test/test_pathod.py | 10 | ||||
-rw-r--r-- | test/tutils.py | 8 |
4 files changed, 26 insertions, 22 deletions
diff --git a/test/test_app.py b/test/test_app.py index 4536db8e..4571617f 100644 --- a/test/test_app.py +++ b/test/test_app.py @@ -7,7 +7,7 @@ class TestApp(tutils.DaemonTests): def test_index(self): r = self.getpath("/") assert r.status_code == 200 - assert r.content + assert r.body def test_about(self): r = self.getpath("/about") @@ -38,48 +38,48 @@ class TestApp(tutils.DaemonTests): def test_response_preview(self): r = self.getpath("/response_preview", params=dict(spec="200")) assert r.status_code == 200 - assert 'Response' in r.content + assert 'Response' in r.body r = self.getpath("/response_preview", params=dict(spec="foo")) assert r.status_code == 200 - assert 'Error' in r.content + assert 'Error' in r.body r = self.getpath("/response_preview", params=dict(spec="200:b@100m")) assert r.status_code == 200 - assert "too large" in r.content + assert "too large" in r.body r = self.getpath("/response_preview", params=dict(spec="200:b@5k")) assert r.status_code == 200 - assert 'Response' in r.content + assert 'Response' in r.body r = self.getpath( "/response_preview", params=dict( spec="200:b<nonexistent")) assert r.status_code == 200 - assert 'File access denied' in r.content + assert 'File access denied' in r.body r = self.getpath("/response_preview", params=dict(spec="200:b<file")) assert r.status_code == 200 - assert 'testfile' in r.content + assert 'testfile' in r.body def test_request_preview(self): r = self.getpath("/request_preview", params=dict(spec="get:/")) assert r.status_code == 200 - assert 'Request' in r.content + assert 'Request' in r.body r = self.getpath("/request_preview", params=dict(spec="foo")) assert r.status_code == 200 - assert 'Error' in r.content + assert 'Error' in r.body r = self.getpath("/request_preview", params=dict(spec="get:/:b@100m")) assert r.status_code == 200 - assert "too large" in r.content + assert "too large" in r.body r = self.getpath("/request_preview", params=dict(spec="get:/:b@5k")) assert r.status_code == 200 - assert 'Request' in r.content + assert 'Request' in r.body r = self.getpath("/request_preview", params=dict(spec="")) assert r.status_code == 200 - assert 'empty spec' in r.content + assert 'empty spec' in r.body diff --git a/test/test_pathoc.py b/test/test_pathoc.py index e9d1e6ab..215f691b 100644 --- a/test/test_pathoc.py +++ b/test/test_pathoc.py @@ -45,7 +45,7 @@ class _TestDaemon: ) c.connect() resp = c.request("get:/api/info") - assert tuple(json.loads(resp.content)["version"]) == version.IVERSION + assert tuple(json.loads(resp.body)["version"]) == version.IVERSION def tval( self, @@ -105,7 +105,7 @@ class TestDaemonSSL(_TestDaemon): c.connect() c.request("get:/p/200") r = c.request("get:/api/log") - d = json.loads(r.content) + d = json.loads(r.body) assert d["log"][0]["request"]["sni"] == "foobar.com" def test_showssl(self): @@ -121,7 +121,7 @@ class TestDaemonSSL(_TestDaemon): c.connect() c.request("get:/p/200") r = c.request("get:/api/log") - d = json.loads(r.content) + d = json.loads(r.body) assert d["log"][0]["request"]["clientcert"]["keyinfo"] def test_http2_without_ssl(self): diff --git a/test/test_pathod.py b/test/test_pathod.py index c8060594..4adc9c22 100644 --- a/test/test_pathod.py +++ b/test/test_pathod.py @@ -51,7 +51,7 @@ class TestNoApi(tutils.DaemonTests): assert self.getpath("/log").status_code == 404 r = self.getpath("/") assert r.status_code == 200 - assert not "Log" in r.content + assert not "Log" in r.body class TestNotAfterConnect(tutils.DaemonTests): @@ -119,7 +119,7 @@ class TestNocraft(tutils.DaemonTests): def test_nocraft(self): r = self.get(r"200:b'\xf0'") assert r.status_code == 800 - assert "Crafting disabled" in r.content + assert "Crafting disabled" in r.body class CommonTests(tutils.DaemonTests): @@ -152,7 +152,7 @@ class CommonTests(tutils.DaemonTests): def test_disconnect(self): rsp = self.get("202:b@100k:d200") - assert len(rsp.content) < 200 + assert len(rsp.body) < 200 def test_parserr(self): rsp = self.get("400:msg,b:") @@ -161,7 +161,7 @@ class CommonTests(tutils.DaemonTests): def test_static(self): rsp = self.get("200:b<file") assert rsp.status_code == 200 - assert rsp.content.strip() == "testfile" + assert rsp.body.strip() == "testfile" def test_anchor(self): rsp = self.getpath("anchor/foo") @@ -201,7 +201,7 @@ class CommonTests(tutils.DaemonTests): def test_source_access_denied(self): rsp = self.get("200:b</foo") assert rsp.status_code == 800 - assert "File access denied" in rsp.content + assert "File access denied" in rsp.body def test_proxy(self): r, _ = self.pathoc([r"get:'http://foo.com/p/202':da"]) diff --git a/test/tutils.py b/test/tutils.py index f7fcc312..a728e852 100644 --- a/test/tutils.py +++ b/test/tutils.py @@ -62,7 +62,7 @@ class DaemonTests(object): def getpath(self, path, params=None): scheme = "https" if self.ssl else "http" - return requests.get( + resp = requests.get( "%s://localhost:%s/%s" % ( scheme, self.d.port, @@ -71,9 +71,13 @@ class DaemonTests(object): verify=False, params=params ) + resp.body = resp.content + return resp def get(self, spec): - return requests.get(self.d.p(spec), verify=False) + resp = requests.get(self.d.p(spec), verify=False) + resp.body = resp.content + return resp def pathoc( self, |