Exemple #1
0
def test_url_completion(qtmodeltester, config_stub, web_history, quickmarks,
                        bookmarks):
    """Test the results of url completion.

    Verify that:
        - quickmarks, bookmarks, and urls are included
        - no more than 'web-history-max-items' history entries are included
        - the most recent entries are included
    """
    config_stub.data['completion'] = {'timestamp-format': '%Y-%m-%d',
                                      'web-history-max-items': 2}
    model = urlmodel.UrlCompletionModel()
    qtmodeltester.data_display_may_return_none = True
    qtmodeltester.check(model)

    _check_completions(model, {
        "Quickmarks": [
            ('https://wiki.archlinux.org', 'aw', ''),
            ('https://duckduckgo.com', 'ddg', ''),
            ('https://wikipedia.org', 'wiki', ''),
        ],
        "Bookmarks": [
            ('https://github.com', 'GitHub', ''),
            ('https://python.org', 'Welcome to Python.org', ''),
            ('http://qutebrowser.org', 'qutebrowser | qutebrowser', ''),
        ],
        "History": [
            ('https://python.org', 'Welcome to Python.org', '2016-03-08'),
            ('https://github.com', 'GitHub', '2016-05-01'),
        ],
    })
Exemple #2
0
def test_url_completion(config_stub, web_history, quickmarks, bookmarks):
    """Test the results of url completion.

    Verify that:
        - quickmarks, bookmarks, and urls are included
        - no more than 'web-history-max-items' history entries are included
        - the most recent entries are included
    """
    config_stub.data['completion'] = {
        'timestamp-format': '%Y-%m-%d',
        'web-history-max-items': 2
    }
    actual = _get_completions(urlmodel.UrlCompletionModel())
    assert actual == [
        ("Quickmarks", [
            ('https://wiki.archlinux.org', 'aw', ''),
            ('https://duckduckgo.com', 'ddg', ''),
            ('https://wikipedia.org', 'wiki', ''),
        ]),
        ("Bookmarks", [
            ('https://github.com', 'GitHub', ''),
            ('https://python.org', 'Welcome to Python.org', ''),
            ('http://qutebrowser.org', 'qutebrowser | qutebrowser', ''),
        ]),
        ("History", [
            ('https://python.org', 'Welcome to Python.org', '2016-03-08'),
            ('https://github.com', 'GitHub', '2016-05-01'),
        ]),
    ]
Exemple #3
0
 def bench():
     model = urlmodel.UrlCompletionModel()
     filtermodel = sortfilter.CompletionFilterModel(model)
     filtermodel.set_pattern('')
     filtermodel.set_pattern('e')
     filtermodel.set_pattern('ex')
     filtermodel.set_pattern('ex ')
     filtermodel.set_pattern('ex 1')
     filtermodel.set_pattern('ex 12')
     filtermodel.set_pattern('ex 123')
Exemple #4
0
def test_url_completion_delete_quickmark(config_stub, web_history, quickmarks,
                                         bookmarks, qtbot):
    """Test deleting a bookmark from the url completion model."""
    config_stub.data['completion'] = {
        'timestamp-format': '%Y-%m-%d',
        'web-history-max-items': 2
    }
    model = urlmodel.UrlCompletionModel()
    # delete item (0, 1) -> (quickmarks, 'ddg' )
    view = _mock_view_index(model, 0, 1, qtbot)
    model.delete_cur_item(view)
    assert 'aw' in quickmarks.marks
    assert 'ddg' not in quickmarks.marks
    assert 'wiki' in quickmarks.marks
Exemple #5
0
def test_url_completion_delete_bookmark(config_stub, web_history, quickmarks,
                                        bookmarks, qtbot):
    """Test deleting a bookmark from the url completion model."""
    config_stub.data['completion'] = {
        'timestamp-format': '%Y-%m-%d',
        'web-history-max-items': 2
    }
    model = urlmodel.UrlCompletionModel()
    # delete item (1, 0) -> (bookmarks, 'https://github.com' )
    view = _mock_view_index(model, 1, 0, qtbot)
    model.delete_cur_item(view)
    assert 'https://github.com' not in bookmarks.marks
    assert 'https://python.org' in bookmarks.marks
    assert 'http://qutebrowser.org' in bookmarks.marks
Exemple #6
0
def _init_url_completion():
    """Initialize the URL completion model."""
    log.completion.debug("Initializing URL completion.")
    with debug.log_time(log.completion, 'URL completion init'):
        model = urlmodel.UrlCompletionModel()
        _instances[usertypes.Completion.url] = model