From 155710f9912f0a7370deab2bef6ad0a51ce47f2b Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sat, 2 Mar 2013 16:57:00 +1300 Subject: Improve robustness of proxy CONNECT, test coverage to 100%. --- test/test_pathoc.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/test_pathoc.py') diff --git a/test/test_pathoc.py b/test/test_pathoc.py index 52a1b5ee..5391167f 100644 --- a/test/test_pathoc.py +++ b/test/test_pathoc.py @@ -2,6 +2,10 @@ import json, cStringIO from libpathod import pathoc, test, version import tutils +def test_response(): + r = pathoc.Response("1.1", 200, "Message", {}, None) + assert repr(r) + class _TestDaemon: @classmethod @@ -126,3 +130,19 @@ class TestDaemon(_TestDaemon): assert "foo" in self.tval(["+%s"%d], showreq=True) assert "File" in self.tval(["+/nonexistent"]) + def test_connect_fail(self): + to = ("foobar", 80) + c = pathoc.Pathoc("127.0.0.1", self.d.port) + r, w = cStringIO.StringIO(), cStringIO.StringIO() + tutils.raises("connect failed", c.http_connect, to, w, r) + r = cStringIO.StringIO( + "HTTP/1.1 500 OK\r\n" + ) + tutils.raises("connect failed", c.http_connect, to, w, r) + r = cStringIO.StringIO( + "HTTP/1.1 200 OK\r\n" + ) + c.http_connect(to, w, r) + + + -- cgit v1.2.3