aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2016-06-08 10:44:20 +1200
committerAldo Cortesi <aldo@nullcube.com>2016-06-08 10:44:20 +1200
commita388ddfd781fd05a414c07cac8446ef151cbd1d2 (patch)
treead0181e2bfd3408c4e5398e5959da914612dc54b /test
parent982077ec31ddffeab9830a02b425c35cb0b0dac5 (diff)
downloadmitmproxy-a388ddfd781fd05a414c07cac8446ef151cbd1d2.tar.gz
mitmproxy-a388ddfd781fd05a414c07cac8446ef151cbd1d2.tar.bz2
mitmproxy-a388ddfd781fd05a414c07cac8446ef151cbd1d2.zip
A new interface for reply
Reply is now explicit - it's no longer a callable itself. Instead, we have: reply.kill() - kill the flow reply.ack() - ack, but don't send anything reply.send(message) - send a response This is part of an incremental move to detach reply from our flow objects, and unify the script and handler interfaces.
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/test_controller.py10
-rw-r--r--test/mitmproxy/test_server.py4
2 files changed, 7 insertions, 7 deletions
diff --git a/test/mitmproxy/test_controller.py b/test/mitmproxy/test_controller.py
index 83ad428e..5a68e15b 100644
--- a/test/mitmproxy/test_controller.py
+++ b/test/mitmproxy/test_controller.py
@@ -66,7 +66,7 @@ class TestChannel(object):
def reply():
m, obj = q.get()
assert m == "test"
- obj.reply(42)
+ obj.reply.send(42)
Thread(target=reply).start()
@@ -86,7 +86,7 @@ class TestDummyReply(object):
def test_simple(self):
reply = controller.DummyReply()
assert not reply.acked
- reply()
+ reply.ack()
assert reply.acked
@@ -94,16 +94,16 @@ class TestReply(object):
def test_simple(self):
reply = controller.Reply(42)
assert not reply.acked
- reply("foo")
+ reply.send("foo")
assert reply.acked
assert reply.q.get() == "foo"
def test_default(self):
reply = controller.Reply(42)
- reply()
+ reply.ack()
assert reply.q.get() == 42
def test_reply_none(self):
reply = controller.Reply(42)
- reply(None)
+ reply.send(None)
assert reply.q.get() is None
diff --git a/test/mitmproxy/test_server.py b/test/mitmproxy/test_server.py
index 1cd6cb0c..432340c0 100644
--- a/test/mitmproxy/test_server.py
+++ b/test/mitmproxy/test_server.py
@@ -743,7 +743,7 @@ class MasterFakeResponse(tservers.TestMaster):
@controller.handler
def request(self, f):
resp = HTTPResponse.wrap(netlib.tutils.tresp())
- f.reply(resp)
+ f.reply.send(resp)
class TestFakeResponse(tservers.HTTPProxyTest):
@@ -819,7 +819,7 @@ class MasterIncomplete(tservers.TestMaster):
def request(self, f):
resp = HTTPResponse.wrap(netlib.tutils.tresp())
resp.content = None
- f.reply(resp)
+ f.reply.send(resp)
class TestIncompleteResponse(tservers.HTTPProxyTest):