Пример #1
0
def test_command_completion(qtmodeltester, monkeypatch, stubs, config_stub,
                            key_config_stub):
    """Test the results of command completion.

    Validates that:
        - only non-hidden and 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
    """
    _patch_cmdutils(monkeypatch, stubs,
                    'qutebrowser.completion.models.miscmodels.cmdutils')
    config_stub.data['aliases'] = {'rock': 'roll'}
    key_config_stub.set_bindings_for('normal', {'s': 'stop',
                                                'rr': 'roll',
                                                'ro': 'rock'})
    model = miscmodels.CommandCompletionModel()
    qtmodeltester.data_display_may_return_none = True
    qtmodeltester.check(model)

    _check_completions(model, {
        "Commands": [
            ('stop', 'stop qutebrowser', 's'),
            ('drop', 'drop all user data', ''),
            ('roll', 'never gonna give you up', 'rr'),
            ('rock', "Alias for 'roll'", 'ro'),
        ]
    })
Пример #2
0
def test_command_completion(monkeypatch, stubs, config_stub, key_config_stub):
    """Test the results of command completion.

    Validates that:
        - only non-hidden and non-deprecated commands are included
        - commands are sorted by name
        - the command description is shown in the desc column
        - the binding (if any) is shown in the misc column
        - aliases are included
    """
    _patch_cmdutils(monkeypatch, stubs,
                    'qutebrowser.completion.models.miscmodels.cmdutils')
    config_stub.data['aliases'] = {'rock': 'roll'}
    key_config_stub.set_bindings_for('normal', {'s': 'stop', 'rr': 'roll'})
    actual = _get_completions(miscmodels.CommandCompletionModel())
    assert actual == [("Commands", [('drop', 'drop all user data', ''),
                                    ('rock', "Alias for 'roll'", ''),
                                    ('roll', 'never gonna give you up', 'rr'),
                                    ('stop', 'stop qutebrowser', 's')])]
Пример #3
0
def _init_command_completion():
    """Initialize the command completion model."""
    log.completion.debug("Initializing command completion.")
    model = miscmodels.CommandCompletionModel()
    _instances[usertypes.Completion.command] = model