diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-06-30 10:51:13 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-06-30 10:51:13 +1200 |
commit | 2cb55ee0f5b00c2c3f4f6d9ba9360c31b82b095c (patch) | |
tree | 585965edd2745d565251003877eee8e845afdcce /test/test_pathoc.py | |
parent | 654a84174adbb323423d4a5a0a9c3945df073610 (diff) | |
download | mitmproxy-2cb55ee0f5b00c2c3f4f6d9ba9360c31b82b095c.tar.gz mitmproxy-2cb55ee0f5b00c2c3f4f6d9ba9360c31b82b095c.tar.bz2 mitmproxy-2cb55ee0f5b00c2c3f4f6d9ba9360c31b82b095c.zip |
Factor out request printing in to a method, and test it.
Diffstat (limited to 'test/test_pathoc.py')
-rw-r--r-- | test/test_pathoc.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/test/test_pathoc.py b/test/test_pathoc.py index c6128e22..a9c38870 100644 --- a/test/test_pathoc.py +++ b/test/test_pathoc.py @@ -1,9 +1,8 @@ -import json +import json, cStringIO from libpathod import pathoc, test, version import tutils - class TestDaemon: @classmethod def setUpAll(self): @@ -25,3 +24,20 @@ class TestDaemon: _, _, _, _, content = c.request("get:/api/info") assert tuple(json.loads(content)["version"]) == version.IVERSION + def tval(self, requests, verbose=False): + c = pathoc.Pathoc("127.0.0.1", self.d.port) + c.connect() + s = cStringIO.StringIO() + c.print_requests(requests, verbose, s) + return s.getvalue() + + def test_print_requests(self): + reqs = [ "get:/api/info", "get:/api/info" ] + assert self.tval(reqs, False).count("200") == 2 + assert self.tval(reqs, True).count("Date") == 2 + + def test_parse_err(self): + assert "Error parsing" in self.tval(["foo"]) + + def test_conn_err(self): + assert "Invalid server response" in self.tval(["get:'/p/200:d2'"]) |