This commit is contained in:
Maximilian Hils 2016-03-20 22:58:35 +01:00
parent 2ce023a991
commit 726536689b
3 changed files with 22 additions and 52 deletions

View File

@ -248,7 +248,7 @@ class ServerPlaybackState:
r = flow.request
_, _, path, _, query, _ = urllib.parse.urlparse(r.url)
queriesArray = urllib.parse_qsl(query, keep_blank_values=True)
queriesArray = urllib.parse.parse_qsl(query, keep_blank_values=True)
key = [
str(r.port),

View File

@ -78,43 +78,13 @@ class TestParsing:
class TestMatching:
def req(self):
headers = Headers(header="qvalue")
req = http.HTTPRequest(
"absolute",
"GET",
"http",
"host",
80,
"/path",
b"HTTP/1.1",
headers,
"content_request",
None,
None
)
f = http.HTTPFlow(tutils.tclient_conn(), None)
f.request = req
return f
return tutils.tflow()
def resp(self):
f = self.req()
headers = Headers([["header_response", "svalue"]])
f.response = http.HTTPResponse(
b"HTTP/1.1",
200,
"OK",
headers,
"content_response",
None,
None)
return f
return tutils.tflow(resp=True)
def err(self):
f = self.req()
f.error = Error("msg")
return f
return tutils.tflow(err=True)
def q(self, q, o):
return filt.parse(q)(o)
@ -168,34 +138,34 @@ class TestMatching:
assert self.q("~h 'header: qvalue'", q)
assert self.q("~h 'header: qvalue'", s)
assert self.q("~h 'header_response: svalue'", s)
assert self.q("~h 'header-response: svalue'", s)
assert self.q("~hq 'header: qvalue'", s)
assert not self.q("~hq 'header_response: svalue'", s)
assert not self.q("~hq 'header-response: svalue'", s)
assert self.q("~hq 'header: qvalue'", q)
assert not self.q("~hq 'header_request: svalue'", q)
assert not self.q("~hq 'header-request: svalue'", q)
assert not self.q("~hs 'header: qvalue'", s)
assert self.q("~hs 'header_response: svalue'", s)
assert self.q("~hs 'header-response: svalue'", s)
assert not self.q("~hs 'header: qvalue'", q)
def match_body(self, q, s):
assert not self.q("~b nonexistent", q)
assert self.q("~b content", q)
assert self.q("~b response", s)
assert self.q("~b content_request", s)
assert self.q("~b message", s)
assert not self.q("~bq nomatch", s)
assert self.q("~bq content", q)
assert self.q("~bq content", s)
assert not self.q("~bq response", q)
assert not self.q("~bq response", s)
assert not self.q("~bq message", q)
assert not self.q("~bq message", s)
assert not self.q("~bs content", q)
assert self.q("~bs content", s)
assert not self.q("~bs nomatch", s)
assert not self.q("~bs response", q)
assert self.q("~bs response", s)
assert not self.q("~bs content", q)
assert not self.q("~bs content", s)
assert not self.q("~bs message", q)
assert self.q("~bs message", s)
def test_body(self):
q = self.req()
@ -217,18 +187,18 @@ class TestMatching:
def test_domain(self):
q = self.req()
assert self.q("~d host", q)
assert self.q("~d address", q)
assert not self.q("~d none", q)
def test_url(self):
q = self.req()
s = self.resp()
assert self.q("~u host", q)
assert self.q("~u host/path", q)
assert self.q("~u address", q)
assert self.q("~u address:22/path", q)
assert not self.q("~u moo/path", q)
assert self.q("~u host", s)
assert self.q("~u host/path", s)
assert self.q("~u address", s)
assert self.q("~u address:22/path", s)
assert not self.q("~u moo/path", s)
def test_code(self):

View File

@ -116,7 +116,7 @@ class TestClientPlaybackState:
c.clear(c.current)
assert c.done()
q = Queue.Queue()
q = queue.Queue()
fm.state.clear()
fm.tick(q, timeout=0)