unit test coverage ++

This commit is contained in:
Aldo Cortesi 2011-03-20 18:52:16 +13:00
parent c726519e73
commit c0bd1a39e4
5 changed files with 27 additions and 13 deletions

View File

@ -163,9 +163,6 @@ class Request(controller.Msg):
else:
return True
def is_cached(self):
return False
def load_state(self, state):
if state["client_conn"]:
if self.client_conn:
@ -241,9 +238,6 @@ class Request(controller.Msg):
def is_response(self):
return False
def assemble_proxy(self):
return self.assemble(True)
def assemble(self, _proxy = False):
"""
Assembles the request for transmission to the server. We make some
@ -278,7 +272,6 @@ class Response(controller.Msg):
self.code, self.msg = code, msg
self.headers, self.content = headers, content
self.timestamp = timestamp or utils.timestamp()
self.cached = False
controller.Msg.__init__(self)
self.replay = False
@ -304,9 +297,6 @@ class Response(controller.Msg):
del i["expires"]
return c.output(header="").strip()
def __hash__(self):
return id(self)
def refresh(self, now=None):
"""
This fairly complex and heuristic function refreshes a server
@ -379,9 +369,6 @@ class Response(controller.Msg):
def is_response(self):
return True
def is_cached(self):
return self.cached
def assemble(self):
"""
Assembles the response for transmission to the client. We make some

View File

@ -12,13 +12,18 @@ class uAll(libpry.AutoTree):
assert cmdline.get_common_options(opts)
opts.stickycookie_all = True
opts.stickyauth_all = True
v = cmdline.get_common_options(opts)
assert v["stickycookie"] == ".*"
assert v["stickyauth"] == ".*"
opts.stickycookie_all = False
opts.stickyauth_all = False
opts.stickycookie_filt = "foo"
opts.stickyauth_filt = "foo"
v = cmdline.get_common_options(opts)
assert v["stickycookie"] == "foo"
assert v["stickyauth"] == "foo"

View File

@ -39,6 +39,8 @@ class uState(libpry.AutoTree):
assert c.get_focus() == (f, 0)
c.set_focus(-1)
assert c.get_focus() == (f, 0)
c.set_focus(2)
assert c.get_focus() == (f2, 1)
c.delete_flow(f2)
assert c.get_focus() == (f, 0)

View File

@ -121,6 +121,8 @@ class uDumpMaster(libpry.AutoTree):
def test_stickycookie(self):
ret = self._dummy_cycle(None, "", stickycookie = ".*")
def test_stickyauth(self):
ret = self._dummy_cycle(None, "", stickyauth = ".*")

View File

@ -95,6 +95,9 @@ class uRequest(libpry.AutoTree):
assert r.url() == u
assert r.assemble()
r2 = r.copy()
assert r == r2
def test_anticache(self):
h = utils.Headers()
r = proxy.Request(None, "host", 22, "https", "GET", "/", h, "content")
@ -121,6 +124,10 @@ class uRequest(libpry.AutoTree):
r.load_state(r2.get_state())
assert r == r2
r2.client_conn = None
r.load_state(r2.get_state())
assert not r.client_conn
class uResponse(libpry.AutoTree):
def test_simple(self):
@ -131,6 +138,9 @@ class uResponse(libpry.AutoTree):
resp = proxy.Response(req, 200, "msg", h.copy(), "content")
assert resp.assemble()
resp2 = resp.copy()
assert resp2 == resp
def test_refresh(self):
r = tutils.tresp()
n = time.time()
@ -190,6 +200,10 @@ class uError(libpry.AutoTree):
assert e == e2
e3 = e.copy()
assert e3 == e
class uProxyError(libpry.AutoTree):
def test_simple(self):
p = proxy.ProxyError(111, "msg")
@ -208,6 +222,10 @@ class uClientConnect(libpry.AutoTree):
assert c == c2
c3 = c.copy()
assert c3 == c
tests = [
uProxyError(),
uRequest(),