aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_flow.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-03-17 11:31:05 +1300
committerAldo Cortesi <aldo@nullcube.com>2012-03-17 11:31:05 +1300
commitc8ae1e85b33e80f0c84ccdc8b3759affe4ef3900 (patch)
tree9302f02475b4fc78fcd9c156cd49193ec8303cdc /test/test_flow.py
parent08f410caccef68f1c41a1ec197d188732c85698d (diff)
downloadmitmproxy-c8ae1e85b33e80f0c84ccdc8b3759affe4ef3900.tar.gz
mitmproxy-c8ae1e85b33e80f0c84ccdc8b3759affe4ef3900.tar.bz2
mitmproxy-c8ae1e85b33e80f0c84ccdc8b3759affe4ef3900.zip
Hooks -> ReplaceHooks
It makes more sense to specialize this, which will let me build a nicer interface for replacement hooks in mitmproxy.
Diffstat (limited to 'test/test_flow.py')
-rw-r--r--test/test_flow.py43
1 files changed, 23 insertions, 20 deletions
diff --git a/test/test_flow.py b/test/test_flow.py
index 8f7551c7..cd4de7ea 100644
--- a/test/test_flow.py
+++ b/test/test_flow.py
@@ -1036,44 +1036,47 @@ class udecoded(libpry.AutoTree):
assert r.content == "foo"
-class uHooks(libpry.AutoTree):
+class uReplaceHooks(libpry.AutoTree):
def test_add_remove(self):
- f = lambda(x): None
- h = flow.Hooks()
- h.add("~q", f)
+ h = flow.ReplaceHooks()
+ h.add("~q", "foo", "bar")
assert h.lst
-
- h.remove("~q", f)
+ h.remove("~q", "foo", "bar")
assert not h.lst
- h.add("~q", f)
- h.add("~s", f)
+ h.add("~q", "foo", "bar")
+ h.add("~s", "foo", "bar")
assert len(h.lst) == 2
- h.remove("~q", f)
+ h.remove("~q", "foo", "bar")
assert len(h.lst) == 1
- h.remove("~q")
+ h.remove("~q", "foo", "bar")
assert len(h.lst) == 1
- h.remove("~s")
+ h.clear()
assert len(h.lst) == 0
- track = []
- def func(x):
- track.append(x)
-
- h.add("~s", func)
-
f = tutils.tflow()
+ f.request.content = "foo"
+ h.add("~s", "foo", "bar")
h.run(f)
- assert not track
+ assert f.request.content == "foo"
f = tutils.tflow_full()
+ f.request.content = "foo"
+ f.response.content = "foo"
h.run(f)
- assert len(track) == 1
+ assert f.response.content == "bar"
+ assert f.request.content == "foo"
+ f = tutils.tflow()
+ h.clear()
+ h.add("~q", "foo", "bar")
+ f.request.content = "foo"
+ h.run(f)
+ assert f.request.content == "bar"
tests = [
- uHooks(),
+ uReplaceHooks(),
uStickyCookieState(),
uStickyAuthState(),
uServerPlaybackState(),