From 08f410caccef68f1c41a1ec197d188732c85698d Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Fri, 16 Mar 2012 17:13:11 +1300 Subject: Add a hooks mechanism, based on filter expressions. --- test/test_flow.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'test') 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(), -- cgit v1.2.3