aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-07-23 16:28:34 +1200
committerAldo Cortesi <aldo@nullcube.com>2012-07-23 16:28:34 +1200
commite354974787db631c6bacc7dd014cb7e2bac5ff9c (patch)
tree7affc3e7cb6d799bb821e580192e0fcb0c26d10e
parent773ada882dcd21bcb71d82cd69c1cd96d230c0e0 (diff)
downloadmitmproxy-e354974787db631c6bacc7dd014cb7e2bac5ff9c.tar.gz
mitmproxy-e354974787db631c6bacc7dd014cb7e2bac5ff9c.tar.bz2
mitmproxy-e354974787db631c6bacc7dd014cb7e2bac5ff9c.zip
100% test coverage for app.py
-rw-r--r--test/test_app.py16
-rw-r--r--test/tutils.py6
2 files changed, 19 insertions, 3 deletions
diff --git a/test/test_app.py b/test/test_app.py
index 1078b3a6..84d2e8e5 100644
--- a/test/test_app.py
+++ b/test/test_app.py
@@ -6,7 +6,7 @@ class TestApp(tutils.DaemonTests):
r = self.getpath("/")
assert r.status_code == 200
assert r.content
-
+
def test_docs(self):
assert self.getpath("/docs/pathod").status_code == 200
assert self.getpath("/docs/pathoc").status_code == 200
@@ -21,3 +21,17 @@ class TestApp(tutils.DaemonTests):
assert self.getpath("/log/%s"%id).status_code == 200
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
+
+
diff --git a/test/tutils.py b/test/tutils.py
index 3c1b415e..3b430825 100644
--- a/test/tutils.py
+++ b/test/tutils.py
@@ -20,9 +20,11 @@ class DaemonTests:
def setUp(self):
self.d.clear_log()
- def getpath(self, path):
+ def getpath(self, path, params=None):
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):
scheme = "https" if self.SSL else "http"