diff options
-rw-r--r-- | libpathod/app.py | 2 | ||||
-rw-r--r-- | libpathod/test.py | 15 | ||||
-rw-r--r-- | test/test_pathod.py | 13 | ||||
-rw-r--r-- | test/tutils.py | 7 |
4 files changed, 21 insertions, 16 deletions
diff --git a/libpathod/app.py b/libpathod/app.py index cf66f8d4..17be448d 100644 --- a/libpathod/app.py +++ b/libpathod/app.py @@ -116,7 +116,7 @@ def _preview(is_request): @app.route('/response_preview') def response_preview(): return _preview(False) - + @app.route('/request_preview') def request_preview(): diff --git a/libpathod/test.py b/libpathod/test.py index e8ca536a..5bcebcb6 100644 --- a/libpathod/test.py +++ b/libpathod/test.py @@ -5,9 +5,9 @@ import pathod, utils IFACE = "127.0.0.1" class Daemon: - def __init__(self, staticdir=None, anchors=(), ssl=None, sizelimit=None, noweb=False): + def __init__(self, ssl=None, **daemonargs): self.q = Queue.Queue() - self.thread = PaThread(self.q, staticdir, anchors, ssl, sizelimit, noweb) + self.thread = PaThread(self.q, ssl, daemonargs) self.thread.start() self.port = self.q.get(True, 5) self.urlbase = "%s://%s:%s"%("https" if ssl else "http", IFACE, self.port) @@ -42,10 +42,10 @@ class Daemon: class PaThread(threading.Thread): - def __init__(self, q, staticdir, anchors, ssl, sizelimit, noweb): + def __init__(self, q, ssl, daemonargs): threading.Thread.__init__(self) - self.q, self.staticdir, self.anchors, self.ssl, self.sizelimit = q, staticdir, anchors, ssl, sizelimit - self.noweb = noweb + self.q, self.ssl = q, ssl + self.daemonargs = daemonargs def run(self): if self.ssl is True: @@ -58,10 +58,7 @@ class PaThread(threading.Thread): self.server = pathod.Pathod( (IFACE, 0), ssloptions = ssloptions, - anchors = self.anchors, - staticdir = self.staticdir, - sizelimit = self.sizelimit, - noweb = self.noweb + **self.daemonargs ) self.q.put(self.server.port) self.server.serve_forever() diff --git a/test/test_pathod.py b/test/test_pathod.py index 58477620..036fbf0b 100644 --- a/test/test_pathod.py +++ b/test/test_pathod.py @@ -29,15 +29,20 @@ class TestPathod: class TestNoWeb(tutils.DaemonTests): noweb = True - def setUp(self): - # Over ride log clearing - pass - def test_noweb(self): assert self.get("200").status_code == 200 assert self.getpath("/").status_code == 800 +class TestNoApi(tutils.DaemonTests): + noapi = True + def test_noapi(self): + assert self.getpath("/log").status_code == 404 + r = self.getpath("/") + assert r.status_code == 200 + assert not "Log" in r.content + + class CommonTests(tutils.DaemonTests): def test_sizelimit(self): r = self.get("200:b@1g") diff --git a/test/tutils.py b/test/tutils.py index b1e277e7..1eb78980 100644 --- a/test/tutils.py +++ b/test/tutils.py @@ -5,6 +5,7 @@ import requests class DaemonTests: noweb = False + noapi = False ssl = False @classmethod def setUpAll(self): @@ -13,7 +14,8 @@ class DaemonTests: anchors=[("/anchor/.*", "202")], ssl = self.ssl, sizelimit=1*1024*1024, - noweb = self.noweb + noweb = self.noweb, + noapi = self.noapi ) @classmethod @@ -21,7 +23,8 @@ class DaemonTests: self.d.shutdown() def setUp(self): - self.d.clear_log() + if not (self.noweb or self.noapi): + self.d.clear_log() def getpath(self, path, params=None): scheme = "https" if self.ssl else "http" |