Пример #1
0
def test_command_chain_dispatcher_fofo():
    """Test a mixture of failing and succeeding hooks."""
    fail1 = Fail(u'fail1')
    fail2 = Fail(u'fail2')
    okay1 = Okay(u'okay1')
    okay2 = Okay(u'okay2')

    dp = CommandChainDispatcher([(0, fail1),
                                 # (5, okay1), # add this later
                                 (10, fail2),
                                 (15, okay2)])
    dp.add(okay1, 5)

    nt.assert_equal(dp(), u'okay1')

    nt.assert_true(fail1.called)
    nt.assert_true(okay1.called)
    nt.assert_false(fail2.called)
    nt.assert_false(okay2.called)
Пример #2
0
def test_command_chain_dispatcher_fofo():
    """Test a mixture of failing and succeeding hooks."""
    fail1 = Fail(u'fail1')
    fail2 = Fail(u'fail2')
    okay1 = Okay(u'okay1')
    okay2 = Okay(u'okay2')

    dp = CommandChainDispatcher([(0, fail1),
                                 # (5, okay1), # add this later
                                 (10, fail2),
                                 (15, okay2)])
    dp.add(okay1, 5)

    nt.assert_equal(dp(), u'okay1')

    nt.assert_true(fail1.called)
    nt.assert_true(okay1.called)
    nt.assert_false(fail2.called)
    nt.assert_false(okay2.called)
Пример #3
0
        def push_to_ipython(self):

            c,ip = self.c,self.ip
            if not c:
                return g.trace('can not happen: no c.')

            if not self.ip:
                return g.trace('can not happen: no ip.')

            c.inCommand = False # Disable the command lockout logic

            n = LeoNode(c.p)

            def f(self=self,n=n):
                self.push_ipython_script(n)
                return True
            d = CommandChainDispatcher()
            d.add(f)
            d()
Пример #4
0
def test_command_chain_dispatcher_fofo():
    """Test a mixture of failing and succeeding hooks."""
    fail1 = Fail("fail1")
    fail2 = Fail("fail2")
    okay1 = Okay("okay1")
    okay2 = Okay("okay2")

    dp = CommandChainDispatcher([
        (0, fail1),
        # (5, okay1), # add this later
        (10, fail2),
        (15, okay2)
    ])
    dp.add(okay1, 5)

    assert dp() == "okay1"

    assert fail1.called is True
    assert okay1.called is True
    assert fail2.called is False
    assert okay2.called is False
Пример #5
0
def test_command_chain_dispatcher_eq_priority():
    okay1 = Okay(u'okay1')
    okay2 = Okay(u'okay2')
    dp = CommandChainDispatcher([(1, okay1)])
    dp.add(okay2, 1)
Пример #6
0
def test_command_chain_dispatcher_eq_priority():
    okay1 = Okay(u"okay1")
    okay2 = Okay(u"okay2")
    dp = CommandChainDispatcher([(1, okay1)])
    dp.add(okay2, 1)