def test_bind_completion(qtmodeltester, cmdutils_stub, config_stub,
                         key_config_stub, configdata_stub, info):
    """Test the results of keybinding command completion.

    Validates that:
        - only non-deprecated commands are included
        - the command description is shown in the desc column
        - the binding (if any) is shown in the misc column
        - aliases are included
    """
    model = configmodel.bind('ZQ', info=info)
    model.set_pattern('')
    qtmodeltester.data_display_may_return_none = True
    qtmodeltester.check(model)

    _check_completions(
        model, {
            "Current": [
                ('quit', 'quit qutebrowser', 'ZQ'),
            ],
            "Commands":
            [('open', 'open a url', ''), ('q', "Alias for 'quit'", ''),
             ('quit', 'quit qutebrowser', 'ZQ, <ctrl+q>'),
             ('scroll', 'Scroll the current tab in the given direction.', '')],
        })
Пример #2
0
def test_bind_completion(qtmodeltester, cmdutils_stub, config_stub,
                         key_config_stub, configdata_stub, info):
    """Test the results of keybinding command completion.

    Validates that:
        - only non-deprecated commands are included
        - the command description is shown in the desc column
        - the binding (if any) is shown in the misc column
        - aliases are included
    """
    model = configmodel.bind('ZQ', info=info)
    model.set_pattern('')
    qtmodeltester.data_display_may_return_none = True
    qtmodeltester.check(model)

    _check_completions(model, {
        "Current": [
            ('quit', 'quit qutebrowser', 'ZQ'),
        ],
        "Commands": [
            ('open', 'open a url', ''),
            ('q', "Alias for 'quit'", ''),
            ('quit', 'quit qutebrowser', 'ZQ, <ctrl+q>'),
            ('scroll', 'Scroll the current tab in the given direction.', '')
        ],
    })
def test_bind_completion_no_current(qtmodeltester, cmdutils_stub, config_stub,
                                    key_config_stub, configdata_stub, info):
    """Test keybinding completion with no current binding."""
    model = configmodel.bind('x', info=info)
    model.set_pattern('')
    qtmodeltester.data_display_may_return_none = True
    qtmodeltester.check(model)

    _check_completions(
        model, {
            "Commands":
            [('open', 'open a url', ''), ('q', "Alias for 'quit'", ''),
             ('quit', 'quit qutebrowser', 'ZQ, <ctrl+q>'),
             ('scroll', 'Scroll the current tab in the given direction.', '')],
        })
def test_bind_completion_invalid(cmdutils_stub, config_stub, key_config_stub,
                                 configdata_stub, info):
    """Test command completion with an invalid command bound."""
    model = configmodel.bind('I', info=info)
    model.set_pattern('')

    _check_completions(
        model, {
            "Current": [
                ('invalid', 'Invalid command!', 'I'),
            ],
            "Commands":
            [('open', 'open a url', ''), ('q', "Alias for 'quit'", ''),
             ('quit', 'quit qutebrowser', 'ZQ, <ctrl+q>'),
             ('scroll', 'Scroll the current tab in the given direction.', '')],
        })
Пример #5
0
def test_bind_completion_no_current(qtmodeltester, cmdutils_stub, config_stub,
                                    key_config_stub, configdata_stub, info):
    """Test keybinding completion with no current binding."""
    model = configmodel.bind('x', info=info)
    model.set_pattern('')
    qtmodeltester.data_display_may_return_none = True
    qtmodeltester.check(model)

    _check_completions(model, {
        "Commands": [
            ('open', 'open a url', ''),
            ('q', "Alias for 'quit'", ''),
            ('quit', 'quit qutebrowser', 'ZQ, <ctrl+q>'),
            ('scroll', 'Scroll the current tab in the given direction.', '')
        ],
    })
Пример #6
0
def test_bind_completion_no_binding(qtmodeltester, cmdutils_stub, config_stub,
                                    key_config_stub, configdata_stub, info):
    """Test keybinding completion with no current or default binding."""
    model = configmodel.bind('x', info=info)
    model.set_pattern('')
    qtmodeltester.check(model)

    _check_completions(model, {
        "Commands": [
            ('open', 'open a url', ''),
            ('q', "Alias for 'quit'", ''),
            ('quit', 'quit qutebrowser', 'ZQ, <Ctrl+q>'),
            ('scroll', 'Scroll the current tab in the given direction.', ''),
            ('tab-close', 'Close the current tab.', ''),
        ],
    })
Пример #7
0
def test_bind_completion_no_binding(qtmodeltester, cmdutils_stub, config_stub,
                                    key_config_stub, configdata_stub, info):
    """Test keybinding completion with no current or default binding."""
    model = configmodel.bind('x', info=info)
    model.set_pattern('')
    qtmodeltester.check(model)

    _check_completions(model, {
        "Commands": [
            ('open', 'open a url', ''),
            ('q', "Alias for 'quit'", ''),
            ('quit', 'quit qutebrowser', 'ZQ, <Ctrl+q>'),
            ('scroll', 'Scroll the current tab in the given direction.', ''),
            ('tab-close', 'Close the current tab.', ''),
        ],
    })
Пример #8
0
def test_bind_completion_invalid(cmdutils_stub, config_stub, key_config_stub,
                                 configdata_stub, info):
    """Test command completion with an invalid command bound."""
    model = configmodel.bind('I', info=info)
    model.set_pattern('')

    _check_completions(model, {
        "Current": [
            ('invalid', 'Invalid command!', 'I'),
        ],
        "Commands": [
            ('open', 'open a url', ''),
            ('q', "Alias for 'quit'", ''),
            ('quit', 'quit qutebrowser', 'ZQ, <ctrl+q>'),
            ('scroll', 'Scroll the current tab in the given direction.', '')
        ],
    })
Пример #9
0
def test_bind_completion_invalid_binding(cmdutils_stub, config_stub,
                                         key_config_stub, configdata_stub,
                                         info):
    """Test command completion with an invalid key binding."""
    model = configmodel.bind('<blub>', info=info)
    model.set_pattern('')

    _check_completions(model, {
        "Current/Default": [
            ('', "Could not parse '<blub>': Got invalid key!", '<blub>'),
        ],
        "Commands": [
            ('open', 'open a url', ''),
            ('q', "Alias for 'quit'", ''),
            ('quit', 'quit qutebrowser', 'ZQ, <Ctrl+q>'),
            ('scroll', 'Scroll the current tab in the given direction.', ''),
            ('tab-close', 'Close the current tab.', ''),
        ],
    })
Пример #10
0
def test_bind_completion_invalid_binding(cmdutils_stub, config_stub,
                                         key_config_stub, configdata_stub,
                                         info):
    """Test command completion with an invalid key binding."""
    model = configmodel.bind('<blub>', info=info)
    model.set_pattern('')

    _check_completions(model, {
        "Current/Default": [
            ('', "Could not parse '<blub>': Got invalid key!", '<blub>'),
        ],
        "Commands": [
            ('open', 'open a url', ''),
            ('q', "Alias for 'quit'", ''),
            ('quit', 'quit qutebrowser', 'ZQ, <Ctrl+q>'),
            ('scroll', 'Scroll the current tab in the given direction.', ''),
            ('tab-close', 'Close the current tab.', ''),
        ],
    })
Пример #11
0
def test_bind_completion_changed(cmdutils_stub, config_stub, key_config_stub,
                                 configdata_stub, info):
    """Test command completion with a non-default command bound."""
    model = configmodel.bind('d', info=info)
    model.set_pattern('')

    _check_completions(model, {
        "Current/Default": [
            ('scroll down',
             '(Current) Scroll the current tab in the given direction.', 'd'),
            ('tab-close', '(Default) Close the current tab.', 'd'),
        ],
        "Commands": [
            ('open', 'open a url', ''),
            ('q', "Alias for 'quit'", ''),
            ('quit', 'quit qutebrowser', 'ZQ, <Ctrl+q>'),
            ('scroll', 'Scroll the current tab in the given direction.', ''),
            ('tab-close', 'Close the current tab.', ''),
        ],
    })
Пример #12
0
def test_bind_completion_changed(cmdutils_stub, config_stub, key_config_stub,
                                 configdata_stub, info):
    """Test command completion with a non-default command bound."""
    model = configmodel.bind('d', info=info)
    model.set_pattern('')

    _check_completions(model, {
        "Current/Default": [
            ('scroll down',
             '(Current) Scroll the current tab in the given direction.', 'd'),
            ('tab-close', '(Default) Close the current tab.', 'd'),
        ],
        "Commands": [
            ('open', 'open a url', ''),
            ('q', "Alias for 'quit'", ''),
            ('quit', 'quit qutebrowser', 'ZQ, <Ctrl+q>'),
            ('scroll', 'Scroll the current tab in the given direction.', ''),
            ('tab-close', 'Close the current tab.', ''),
        ],
    })