Example #1
0
 def test_cancel_does_not_invoke_handlers_if_stop_is_set(self):
     m = mock.Mock()
     h = handler.handler()
     h.chain(m)
     h.stop_propagation()
     h.cancel()
     self.assertEqual(0, m.cancel.call_count)
Example #2
0
 def test_cancel_resets_stop_variable(self):
     m = mock.Mock()
     h = handler.handler()
     h.chain(m)
     h.stop_propagation()
     h.cancel()
     self.assertFalse(h.stop)
Example #3
0
    def __init__(self, transport):
        super(simple_session, self).__init__(transport)
        
        lhandler = buffering.buffering(self.on_line, self.on_abort)
        ehandler = echo.echo(transport)
        khandler = keystroke.keystroke()
        khandler.simpleterm_bindings(transport)

        self.noecho = False
        self.ehandler = ehandler
        self.handler = handler.handler()
        self.handler.chain_other(khandler).chain(ehandler, lhandler)
        self.networks = []
Example #4
0
 def test_unhandle_call_all_handlers(self):
     m = mock.Mock()
     h = handler.handler()
     h.chain(m)
     h.unhandle()
     m.unhandle.assert_called_with()
Example #5
0
 def test_cancel_invokes_do_cancel(self):
     with h.mock_value(handler.handler, "do_cancel") as mymock:
         hl = handler.handler()
         hl.do_cancel()
         mymock[0].assert_called_with()
Example #6
0
 def test_cancel_call_all_handlers(self):
     m = mock.Mock()
     h = handler.handler()
     h.chain(m)
     h.cancel()
     m.cancel.assert_called_with()
Example #7
0
 def test_stop_propagation_updates_stop_variable(self):
     h = handler.handler()
     h.stop_propagation()
     self.assertTrue(h.stop)
Example #8
0
 def test_chain_other_appends_to_handlers(self):
     h = handler.handler()
     h.chain_other("foo")
     self.assertEqual(["foo"], h.handlers)
Example #9
0
 def test_chain_other_returns_param(self):
     h = handler.handler()
     self.assertEqual("foo", h.chain_other("foo"))
Example #10
0
 def test_chain_extends_handlers(self):
     h = handler.handler()
     h.chain("foo", "bar")
     self.assertEqual(["foo", "bar"], h.handlers)
Example #11
0
 def test_chain_returns_self(self):
     h = handler.handler()
     self.assertEqual(h, h.chain("foo", "bar"))
Example #12
0
 def test_init(self):
     h = handler.handler()
     self.assertEqual([], h.handlers)
     self.assertFalse(h.stop)