Ejemplo n.º 1
0
 def setUp(self):
     self.aws_shell = AWSShell(mock.Mock(), mock.Mock(), mock.Mock())
     self.toolbar = Toolbar(
         lambda: self.aws_shell.model_completer.match_fuzzy,
         lambda: self.aws_shell.enable_vi_bindings,
         lambda: self.aws_shell.show_completion_columns,
         lambda: self.aws_shell.show_help)
Ejemplo n.º 2
0
class ToolbarTest(unittest.TestCase):
    def setUp(self):
        self.aws_shell = AWSShell(mock.Mock(), mock.Mock(), mock.Mock())
        self.toolbar = Toolbar(
            lambda: self.aws_shell.model_completer.match_fuzzy,
            lambda: self.aws_shell.enable_vi_bindings,
            lambda: self.aws_shell.show_completion_columns,
            lambda: self.aws_shell.show_help)

    def test_toolbar_on(self):
        self.aws_shell.model_completer.match_fuzzy = True
        self.aws_shell.enable_vi_bindings = True
        self.aws_shell.show_completion_columns = True
        self.aws_shell.show_help = True
        expected = [(Token.Toolbar.On, ' [F2] Fuzzy: ON '),
                    (Token.Toolbar.On, ' [F3] Keys: Vi '),
                    (Token.Toolbar.On, ' [F4] Multi Column '),
                    (Token.Toolbar.On, ' [F5] Help: ON '),
                    (Token.Toolbar, ' [F10] Exit ')]
        assert expected == self.toolbar.handler(None)

    def test_toolbar_off(self):
        self.aws_shell.model_completer.match_fuzzy = False
        self.aws_shell.enable_vi_bindings = False
        self.aws_shell.show_completion_columns = False
        self.aws_shell.show_help = False
        expected = [(Token.Toolbar.Off, ' [F2] Fuzzy: OFF '),
                    (Token.Toolbar.On, ' [F3] Keys: Emacs '),
                    (Token.Toolbar.On, ' [F4] Single Column '),
                    (Token.Toolbar.Off, ' [F5] Help: OFF '),
                    (Token.Toolbar, ' [F10] Exit ')]
        assert expected == self.toolbar.handler(None)
Ejemplo n.º 3
0
class ToolbarTest(unittest.TestCase):

    def setUp(self):
        self.aws_shell = AWSShell(mock.Mock(), mock.Mock(), mock.Mock())
        self.toolbar = Toolbar(
            lambda: self.aws_shell.model_completer.match_fuzzy,
            lambda: self.aws_shell.enable_vi_bindings,
            lambda: self.aws_shell.show_completion_columns,
            lambda: self.aws_shell.show_help)

    def test_toolbar_on(self):
        self.aws_shell.model_completer.match_fuzzy = True
        self.aws_shell.enable_vi_bindings = True
        self.aws_shell.show_completion_columns = True
        self.aws_shell.show_help = True
        expected = [
            (Token.Toolbar.On, ' [F2] Fuzzy: ON '),
            (Token.Toolbar.On, ' [F3] Keys: Vi '),
            (Token.Toolbar.On, ' [F4] Multi Column '),
            (Token.Toolbar.On, ' [F5] Help: ON '),
            (Token.Toolbar, ' [F10] Exit ')]
        assert expected == self.toolbar.handler(None)

    def test_toolbar_off(self):
        self.aws_shell.model_completer.match_fuzzy = False
        self.aws_shell.enable_vi_bindings = False
        self.aws_shell.show_completion_columns = False
        self.aws_shell.show_help = False
        expected = [
            (Token.Toolbar.Off, ' [F2] Fuzzy: OFF '),
            (Token.Toolbar.On, ' [F3] Keys: Emacs '),
            (Token.Toolbar.On, ' [F4] Single Column '),
            (Token.Toolbar.Off, ' [F5] Help: OFF '),
            (Token.Toolbar, ' [F10] Exit ')]
        assert expected == self.toolbar.handler(None)
Ejemplo n.º 4
0
 def setUp(self):
     self.aws_shell = AWSShell(mock.Mock(), mock.Mock(), mock.Mock())
     self.toolbar = Toolbar(
         lambda: self.aws_shell.model_completer.match_fuzzy,
         lambda: self.aws_shell.enable_vi_bindings,
         lambda: self.aws_shell.show_completion_columns,
         lambda: self.aws_shell.show_help)
Ejemplo n.º 5
0
    def create_application(self, completer, history,
                           display_completions_in_columns):
        self.key_manager = self.create_key_manager()
        toolbar = Toolbar(lambda: self.model_completer.match_fuzzy,
                          lambda: self.enable_vi_bindings,
                          lambda: self.show_completion_columns,
                          lambda: self.show_help)
        style_factory = StyleFactory(self.theme)
        buffers = {'clidocs': Buffer(read_only=True)}

        if self.enable_vi_bindings:
            editing_mode = EditingMode.VI
        else:
            editing_mode = EditingMode.EMACS

        return Application(
            editing_mode=editing_mode,
            layout=self.create_layout(display_completions_in_columns, toolbar),
            mouse_support=False,
            style=style_factory.style,
            buffers=buffers,
            buffer=self.create_buffer(completer, history),
            on_abort=AbortAction.RETRY,
            on_exit=AbortAction.RAISE_EXCEPTION,
            on_input_timeout=self.on_input_timeout,
            key_bindings_registry=self.key_manager.manager.registry,
        )