예제 #1
0
    def test_calling_registered_hooks(self):
        """
            Test calling registered hooks
        """
        hookregistry = HookRegistry()

        data = threading.local()
        data.called_hooked_a = False
        data.called_hooked_b = False
        data.called_hooked_c = False

        def hooked_a():
            data.called_hooked_a = True

        def hooked_b():
            data.called_hooked_b = True

        def hooked_c():
            data.called_hooked_c = True

        before.each_feature(hooked_a)
        after.each_step(hooked_b)
        before.each_feature(hooked_c)

        hookregistry.call("before", "each_feature")
        data.called_hooked_a.should.be.true
        data.called_hooked_b.should.be.false
        data.called_hooked_c.should.be.true

        hookregistry.call("after", "each_step")
        data.called_hooked_a.should.be.true
        data.called_hooked_b.should.be.true
        data.called_hooked_c.should.be.true
예제 #2
0
    def test_calling_registered_hooks(self):
        """
            Test calling registered hooks
        """
        hookregistry = HookRegistry()

        data = threading.local()
        data.called_hooked_a = False
        data.called_hooked_b = False
        data.called_hooked_c = False

        def hooked_a():
            data.called_hooked_a = True

        def hooked_b():
            data.called_hooked_b = True

        def hooked_c():
            data.called_hooked_c = True

        before.each_feature(hooked_a)
        after.each_step(hooked_b)
        before.each_feature(hooked_c)

        hookregistry.call("before", "each_feature")
        data.called_hooked_a.should.be.true
        data.called_hooked_b.should.be.false
        data.called_hooked_c.should.be.true

        hookregistry.call("after", "each_step")
        data.called_hooked_a.should.be.true
        data.called_hooked_b.should.be.true
        data.called_hooked_c.should.be.true
예제 #3
0
    def test_calling_registered_hooks_with_arguments(self):
        """
            Test calling registered hooks with arguments
        """
        hookregistry = HookRegistry()

        data = threading.local()
        data.hooked_a_feature = None
        data.hooked_b_step = None
        data.hooked_c_feature = None

        def hooked_a(feature):
            data.hooked_a_feature = feature

        def hooked_b(step):
            data.hooked_b_step = step

        def hooked_c(feature):
            data.hooked_c_feature = feature

        before.each_feature(hooked_a)
        after.each_step(hooked_b)
        before.each_feature(hooked_c)

        hookregistry.call("before", "each_feature", "this is a feature")
        data.hooked_a_feature = "this is a feature"
        data.hooked_b_step = None
        data.hooked_c_feature = "this is a feature"

        hookregistry.call("after", "each_step", "this is a step")
        data.hooked_a_feature = "this is a feature"
        data.hooked_b_step = "this is a step"
        data.hooked_c_feature = "this is a feature"
예제 #4
0
    def test_calling_registered_hooks_with_arguments(self):
        """
            Test calling registered hooks with arguments
        """
        hookregistry = HookRegistry()

        data = threading.local()
        data.hooked_a_feature = None
        data.hooked_b_step = None
        data.hooked_c_feature = None

        def hooked_a(feature):
            data.hooked_a_feature = feature

        def hooked_b(step):
            data.hooked_b_step = step

        def hooked_c(feature):
            data.hooked_c_feature = feature

        before.each_feature(hooked_a)
        after.each_step(hooked_b)
        before.each_feature(hooked_c)

        hookregistry.call("before", "each_feature", "this is a feature")
        data.hooked_a_feature = "this is a feature"
        data.hooked_b_step = None
        data.hooked_c_feature = "this is a feature"

        hookregistry.call("after", "each_step", "this is a step")
        data.hooked_a_feature = "this is a feature"
        data.hooked_b_step = "this is a step"
        data.hooked_c_feature = "this is a feature"