mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 16:17:49 +00:00
100% test coverage for app.py
This commit is contained in:
parent
773ada882d
commit
e354974787
@ -21,3 +21,17 @@ class TestApp(tutils.DaemonTests):
|
|||||||
assert self.getpath("/log/%s"%id).status_code == 200
|
assert self.getpath("/log/%s"%id).status_code == 200
|
||||||
assert self.getpath("/log/9999999").status_code == 404
|
assert self.getpath("/log/9999999").status_code == 404
|
||||||
|
|
||||||
|
def test_preview(self):
|
||||||
|
r = self.getpath("/preview", params=dict(spec="200"))
|
||||||
|
assert r.status_code == 200
|
||||||
|
assert 'Response' in r.content
|
||||||
|
|
||||||
|
r = self.getpath("/preview", params=dict(spec="foo"))
|
||||||
|
assert r.status_code == 200
|
||||||
|
assert 'Error' in r.content
|
||||||
|
|
||||||
|
r = self.getpath("/preview", params=dict(spec="200:b@100m"))
|
||||||
|
assert r.status_code == 200
|
||||||
|
assert "too large" in r.content
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,9 +20,11 @@ class DaemonTests:
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.d.clear_log()
|
self.d.clear_log()
|
||||||
|
|
||||||
def getpath(self, path):
|
def getpath(self, path, params=None):
|
||||||
scheme = "https" if self.SSL else "http"
|
scheme = "https" if self.SSL else "http"
|
||||||
return requests.get("%s://localhost:%s/%s"%(scheme, self.d.port, path), verify=False)
|
return requests.get(
|
||||||
|
"%s://localhost:%s/%s"%(scheme, self.d.port, path), verify=False, params=params
|
||||||
|
)
|
||||||
|
|
||||||
def get(self, spec):
|
def get(self, spec):
|
||||||
scheme = "https" if self.SSL else "http"
|
scheme = "https" if self.SSL else "http"
|
||||||
|
Loading…
Reference in New Issue
Block a user