aboutsummaryrefslogtreecommitdiffstats
path: root/test/tutils.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-07-23 16:18:47 +1200
committerAldo Cortesi <aldo@nullcube.com>2012-07-23 16:18:47 +1200
commit773ada882dcd21bcb71d82cd69c1cd96d230c0e0 (patch)
treeed8e6adb94e4836e5034ff985f9bb237afa9d68c /test/tutils.py
parent3027aae142c12b123715e1cb0ecc770f00d27198 (diff)
downloadmitmproxy-773ada882dcd21bcb71d82cd69c1cd96d230c0e0.tar.gz
mitmproxy-773ada882dcd21bcb71d82cd69c1cd96d230c0e0.tar.bz2
mitmproxy-773ada882dcd21bcb71d82cd69c1cd96d230c0e0.zip
Unit tests for most of app.py, return 404 for unknown log entry.
Diffstat (limited to 'test/tutils.py')
-rw-r--r--test/tutils.py37
1 files changed, 36 insertions, 1 deletions
diff --git a/test/tutils.py b/test/tutils.py
index d5609d7b..3c1b415e 100644
--- a/test/tutils.py
+++ b/test/tutils.py
@@ -1,6 +1,41 @@
import tempfile, os, shutil
from contextlib import contextmanager
-from libpathod import utils
+from libpathod import utils, test, pathoc
+import requests
+
+class DaemonTests:
+ @classmethod
+ def setUpAll(self):
+ self.d = test.Daemon(
+ staticdir=test_data.path("data"),
+ anchors=[("/anchor/.*", "202")],
+ ssl = self.SSL,
+ sizelimit=1*1024*1024
+ )
+
+ @classmethod
+ def tearDownAll(self):
+ self.d.shutdown()
+
+ def setUp(self):
+ self.d.clear_log()
+
+ def getpath(self, path):
+ scheme = "https" if self.SSL else "http"
+ return requests.get("%s://localhost:%s/%s"%(scheme, self.d.port, path), verify=False)
+
+ def get(self, spec):
+ scheme = "https" if self.SSL else "http"
+ return requests.get("%s://localhost:%s/p/%s"%(scheme, self.d.port, spec), verify=False)
+
+ def pathoc(self, spec, timeout=None):
+ c = pathoc.Pathoc("localhost", self.d.port)
+ c.connect()
+ if self.SSL:
+ c.convert_to_ssl()
+ if timeout:
+ c.settimeout(timeout)
+ return c.request(spec)