aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-03-16 17:13:11 +1300
committerAldo Cortesi <aldo@nullcube.com>2012-03-16 17:13:11 +1300
commit08f410caccef68f1c41a1ec197d188732c85698d (patch)
tree5a3b07a6f1411d8dab9882aaf909b061ccf3fc13 /test
parentd138af72171d833659cfb53edc80eade121ca836 (diff)
downloadmitmproxy-08f410caccef68f1c41a1ec197d188732c85698d.tar.gz
mitmproxy-08f410caccef68f1c41a1ec197d188732c85698d.tar.bz2
mitmproxy-08f410caccef68f1c41a1ec197d188732c85698d.zip
Add a hooks mechanism, based on filter expressions.
Diffstat (limited to 'test')
-rw-r--r--test/test_flow.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/test_flow.py b/test/test_flow.py
index ff35f899..8f7551c7 100644
--- a/test/test_flow.py
+++ b/test/test_flow.py
@@ -1036,9 +1036,44 @@ class udecoded(libpry.AutoTree):
assert r.content == "foo"
+class uHooks(libpry.AutoTree):
+ def test_add_remove(self):
+ f = lambda(x): None
+ h = flow.Hooks()
+ h.add("~q", f)
+ assert h.lst
+
+ h.remove("~q", f)
+ assert not h.lst
+
+ h.add("~q", f)
+ h.add("~s", f)
+ assert len(h.lst) == 2
+ h.remove("~q", f)
+ assert len(h.lst) == 1
+ h.remove("~q")
+ assert len(h.lst) == 1
+ h.remove("~s")
+ assert len(h.lst) == 0
+
+ track = []
+ def func(x):
+ track.append(x)
+
+ h.add("~s", func)
+
+ f = tutils.tflow()
+ h.run(f)
+ assert not track
+
+ f = tutils.tflow_full()
+ h.run(f)
+ assert len(track) == 1
+
tests = [
+ uHooks(),
uStickyCookieState(),
uStickyAuthState(),
uServerPlaybackState(),