100% test coverage.

This commit is contained in:
Aldo Cortesi 2012-07-30 13:52:40 +12:00
parent 43314c77c8
commit e26aac1d3c
4 changed files with 10 additions and 4 deletions

View File

@ -65,8 +65,10 @@ class Pathoc(tcp.TCPClient):
return
except tcp.NetLibTimeout:
print >> fp, "<<", "Timeout"
except tcp.NetLibDisconnect:
return
except tcp.NetLibDisconnect: # pragma: nocover
print >> fp, "<<", "Disconnect"
return
else:
if respdump:
print_full(fp, *resp)

View File

@ -9,9 +9,6 @@ class PathodError(Exception): pass
class PathodHandler(tcp.BaseHandler):
wbufsize = 0
sni = None
def debug(self, s):
logging.debug("%s:%s: %s"%(self.client_address[0], self.client_address[1], str(s)))
def info(self, s):
logging.info("%s:%s: %s"%(self.client_address[0], self.client_address[1], str(s)))

View File

@ -57,3 +57,4 @@ class TestDaemon:
d = tutils.test_data.path("data/request")
assert "foo" in self.tval(["+%s"%d])
assert "File" in self.tval(["+/nonexistent"])

View File

@ -107,6 +107,12 @@ class CommonTests(tutils.DaemonTests):
assert l["type"] == "error"
assert "Invalid" in l["msg"]
def test_invalid_headers(self):
tutils.raises(http.HttpError, self.pathoc, "get:/:h'\t'='foo'")
l = self.d.log()[0]
assert l["type"] == "error"
assert "Invalid headers" in l["msg"]
def test_access_denied(self):
rsp = self.get("=nonexistent")
assert rsp.status_code == 800