예제 #1
0
def test_url_completion(qtmodeltester, web_history_populated,
                        quickmarks, bookmarks, info):
    """Test the results of url completion.

    Verify that:
        - quickmarks, bookmarks, and urls are included
        - entries are sorted by access time
        - only the most recent entry is included for each url
    """
    model = urlmodel.url(info=info)
    model.set_pattern('')
    qtmodeltester.data_display_may_return_none = True
    qtmodeltester.check(model)

    _check_completions(model, {
        "Quickmarks": [
            ('https://wiki.archlinux.org', 'aw', None),
            ('https://wikipedia.org', 'wiki', None),
            ('https://duckduckgo.com', 'ddg', None),
        ],
        "Bookmarks": [
            ('https://github.com', 'GitHub', None),
            ('https://python.org', 'Welcome to Python.org', None),
            ('http://qutebrowser.org', 'qutebrowser | qutebrowser', None),
        ],
        "History": [
            ('https://github.com', 'https://github.com', '2016-05-01'),
            ('https://python.org', 'Welcome to Python.org', '2016-03-08'),
            ('http://qutebrowser.org', 'qutebrowser', '2015-09-05'),
        ],
    })
예제 #2
0
def test_search_only_default(qtmodeltester, config_stub, web_history_populated,
                             quickmarks, bookmarks, info):
    """Test that search engines are not shown with only the default engine."""
    config_stub.val.completion.open_categories = [
        "searchengines",
        "quickmarks",
        "bookmarks",
        "history",
    ]
    config_stub.val.url.searchengines = {
        "DEFAULT": "https://duckduckgo.com/?q={}",
    }
    model = urlmodel.url(info=info)
    model.set_pattern('')
    qtmodeltester.check(model)

    _check_completions(model, {
        "Quickmarks": [
            ('https://wiki.archlinux.org', 'aw', None),
            ('https://wikipedia.org', 'wiki', None),
            ('https://duckduckgo.com', 'ddg', None),
        ],
        "Bookmarks": [
            ('https://github.com', 'GitHub', None),
            ('https://python.org', 'Welcome to Python.org', None),
            ('http://qutebrowser.org', 'qutebrowser | qutebrowser', None),
        ],
        "History": [
            ('https://github.com', 'https://github.com', '2016-05-01'),
            ('https://python.org', 'Welcome to Python.org', '2016-03-08'),
            ('http://qutebrowser.org', 'qutebrowser', '2015-09-05'),
        ],
    })
예제 #3
0
def test_open_categories_remove_one(qtmodeltester, config_stub, web_history_populated,
                                    quickmarks, bookmarks, info):
    """Test removing an item (boookmarks) from open_categories."""
    config_stub.val.url.searchengines = {
        "DEFAULT": "https://duckduckgo.com/?q={}",
        "google": "https://google.com/?q={}",
    }
    config_stub.val.completion.open_categories = [
        "searchengines", "quickmarks", "history"]
    model = urlmodel.url(info=info)
    model.set_pattern('')
    qtmodeltester.check(model)

    _check_completions(model, {
        "Search engines": [
            ('google', 'https://google.com/?q={}', None),
        ],
        "Quickmarks": [
            ('https://wiki.archlinux.org', 'aw', None),
            ('https://wikipedia.org', 'wiki', None),
            ('https://duckduckgo.com', 'ddg', None),
        ],
        "History": [
            ('https://github.com', 'https://github.com', '2016-05-01'),
            ('https://python.org', 'Welcome to Python.org', '2016-03-08'),
            ('http://qutebrowser.org', 'qutebrowser', '2015-09-05'),
        ],
    })
예제 #4
0
def test_url_completion_zero_limit(config_stub, web_history, quickmarks, info,
                                   bookmarks):
    """Make sure there's no history if the limit was set to zero."""
    config_stub.val.completion.web_history_max_items = 0
    model = urlmodel.url(info=info)
    model.set_pattern('')
    category = model.index(2, 0)  # "History" normally
    assert model.data(category) is None
예제 #5
0
 def bench():
     model = urlmodel.url(info=info)
     model.set_pattern('')
     model.set_pattern('e')
     model.set_pattern('ex')
     model.set_pattern('ex ')
     model.set_pattern('ex 1')
     model.set_pattern('ex 12')
     model.set_pattern('ex 123')
예제 #6
0
def test_url_completion_pattern(web_history, quickmark_manager_stub,
                                bookmark_manager_stub, info,
                                url, title, pattern, rowcount):
    """Test that url completion filters by url and title."""
    web_history.add_url(QUrl(url), title)
    model = urlmodel.url(info=info)
    model.set_pattern(pattern)
    # 2, 0 is History
    assert model.rowCount(model.index(2, 0)) == rowcount
예제 #7
0
def test_open_categories_remove_all(qtmodeltester, config_stub, web_history_populated,
                                    quickmarks, bookmarks, info):
    """Test removing all items from open_categories."""
    config_stub.val.url.searchengines = {
        "DEFAULT": "https://duckduckgo.com/?q={}",
        "google": "https://google.com/?q={}",
    }
    config_stub.val.completion.open_categories = []
    model = urlmodel.url(info=info)
    model.set_pattern('')
    qtmodeltester.check(model)

    _check_completions(model, {})
예제 #8
0
def test_url_completion_zero_limit(config_stub, web_history, quickmarks, info,
                                   bookmarks):
    """Make sure there's no history if the limit was set to zero."""
    config_stub.val.completion.web_history.max_items = 0
    config_stub.val.completion.open_categories = [
        "searchengines",
        "quickmarks",
        "bookmarks",
        "history",
    ]
    config_stub.val.url.searchengines = {
        "DEFAULT": "https://duckduckgo.com/?q={}",
        "google": "https://google.com/?q={}",
    }
    model = urlmodel.url(info=info)
    model.set_pattern('')
    category = model.index(3, 0)  # "History" normally
    assert model.data(category) is None
예제 #9
0
def test_url_completion_delete_history(qtmodeltester, info,
                                       web_history_populated,
                                       quickmarks, bookmarks):
    """Test deleting a history entry."""
    model = urlmodel.url(info=info)
    model.set_pattern('')
    qtmodeltester.check(model)

    parent = model.index(2, 0)
    idx = model.index(1, 0, parent)

    # sanity checks
    assert model.data(parent) == "History"
    assert model.data(idx) == 'https://python.org'

    assert 'https://python.org' in web_history_populated
    model.delete_cur_item(idx)
    assert 'https://python.org' not in web_history_populated
예제 #10
0
def test_url_completion(qtmodeltester, config_stub, web_history_populated,
                        quickmarks, bookmarks, info):
    """Test the results of url completion.

    Verify that:
        - searchengines, quickmarks, bookmarks, and urls are included
        - default search engine is not displayed
        - entries are sorted by access time
        - only the most recent entry is included for each url
    """
    config_stub.val.completion.open_categories = [
        "searchengines",
        "quickmarks",
        "bookmarks",
        "history",
    ]
    config_stub.val.url.searchengines = {
        "DEFAULT": "https://duckduckgo.com/?q={}",
        "google": "https://google.com/?q={}"
    }
    model = urlmodel.url(info=info)
    model.set_pattern('')
    qtmodeltester.check(model)

    _check_completions(model, {
        "Search engines": [
            ('google', 'https://google.com/?q={}', None),
        ],
        "Quickmarks": [
            ('https://wiki.archlinux.org', 'aw', None),
            ('https://wikipedia.org', 'wiki', None),
            ('https://duckduckgo.com', 'ddg', None),
        ],
        "Bookmarks": [
            ('https://github.com', 'GitHub', None),
            ('https://python.org', 'Welcome to Python.org', None),
            ('http://qutebrowser.org', 'qutebrowser | qutebrowser', None),
        ],
        "History": [
            ('https://github.com', 'https://github.com', '2016-05-01'),
            ('https://python.org', 'Welcome to Python.org', '2016-03-08'),
            ('http://qutebrowser.org', 'qutebrowser', '2015-09-05'),
        ],
    })
예제 #11
0
def test_url_completion(qtmodeltester, config_stub, web_history_populated,
                        quickmarks, bookmarks, info):
    """Test the results of url completion.

    Verify that:
        - searchengines, quickmarks, bookmarks, and urls are included
        - default search engine is not displayed
        - entries are sorted by access time
        - only the most recent entry is included for each url
    """
    config_stub.val.completion.open_categories = [
        "searchengines",
        "quickmarks",
        "bookmarks",
        "history",
    ]
    config_stub.val.url.searchengines = {
        "DEFAULT": "https://duckduckgo.com/?q={}",
        "google": "https://google.com/?q={}"
    }
    model = urlmodel.url(info=info)
    model.set_pattern('')
    qtmodeltester.check(model)

    _check_completions(model, {
        "Search engines": [
            ('google', 'https://google.com/?q={}', None),
        ],
        "Quickmarks": [
            ('https://wiki.archlinux.org', 'aw', None),
            ('https://wikipedia.org', 'wiki', None),
            ('https://duckduckgo.com', 'ddg', None),
        ],
        "Bookmarks": [
            ('https://github.com', 'GitHub', None),
            ('https://python.org', 'Welcome to Python.org', None),
            ('http://qutebrowser.org', 'qutebrowser | qutebrowser', None),
        ],
        "History": [
            ('https://github.com', 'https://github.com', '2016-05-01'),
            ('https://python.org', 'Welcome to Python.org', '2016-03-08'),
            ('http://qutebrowser.org', 'qutebrowser', '2015-09-05'),
        ],
    })
예제 #12
0
def test_url_completion_no_bookmarks(qtmodeltester, web_history_populated,
                                     quickmarks, bookmark_manager_stub, info):
    """Test that the bookmarks category is gone with no bookmarks."""
    model = urlmodel.url(info=info)
    model.set_pattern('')
    qtmodeltester.check(model)

    _check_completions(model, {
        "Quickmarks": [
            ('https://wiki.archlinux.org', 'aw', None),
            ('https://wikipedia.org', 'wiki', None),
            ('https://duckduckgo.com', 'ddg', None),
        ],
        "History": [
            ('https://github.com', 'https://github.com', '2016-05-01'),
            ('https://python.org', 'Welcome to Python.org', '2016-03-08'),
            ('http://qutebrowser.org', 'qutebrowser', '2015-09-05'),
        ],
    })
예제 #13
0
def test_url_completion_delete_quickmark(qtmodeltester, info, qtbot,
                                         quickmarks, web_history, bookmarks):
    """Test deleting a bookmark from the url completion model."""
    model = urlmodel.url(info=info)
    model.set_pattern('')
    qtmodeltester.check(model)

    parent = model.index(0, 0)
    idx = model.index(0, 0, parent)

    # sanity checks
    assert model.data(parent) == "Quickmarks"
    assert model.data(idx) == 'https://wiki.archlinux.org'
    assert 'ddg' in quickmarks.marks

    len_before = len(quickmarks.marks)
    model.delete_cur_item(idx)
    assert 'aw' not in quickmarks.marks
    assert len_before == len(quickmarks.marks) + 1
예제 #14
0
def test_url_completion_delete_bookmark(qtmodeltester, bookmarks,
                                        web_history, quickmarks, info):
    """Test deleting a bookmark from the url completion model."""
    model = urlmodel.url(info=info)
    model.set_pattern('')
    qtmodeltester.check(model)

    parent = model.index(1, 0)
    idx = model.index(1, 0, parent)

    # sanity checks
    assert model.data(parent) == "Bookmarks"
    assert model.data(idx) == 'https://python.org'
    assert 'https://github.com' in bookmarks.marks

    len_before = len(bookmarks.marks)
    model.delete_cur_item(idx)
    assert 'https://python.org' not in bookmarks.marks
    assert len_before == len(bookmarks.marks) + 1
예제 #15
0
def test_url_completion_no_quickmarks(qtmodeltester, web_history_populated,
                                      quickmark_manager_stub, bookmarks, info):
    """Test that the quickmark category is gone with no quickmarks."""
    model = urlmodel.url(info=info)
    model.set_pattern('')
    qtmodeltester.check(model)

    _check_completions(model, {
        "Bookmarks": [
            ('https://github.com', 'GitHub', None),
            ('https://python.org', 'Welcome to Python.org', None),
            ('http://qutebrowser.org', 'qutebrowser | qutebrowser', None),
        ],
        "History": [
            ('https://github.com', 'https://github.com', '2016-05-01'),
            ('https://python.org', 'Welcome to Python.org', '2016-03-08'),
            ('http://qutebrowser.org', 'qutebrowser', '2015-09-05'),
        ],
    })
예제 #16
0
def test_open_categories_remove_all(qtmodeltester, config_stub,
                                    web_history_populated, quickmarks,
                                    bookmarks, info):
    """Test that removing an item (boookmarks) from the open_categories settings has the desired effect.

    Verify that:
        - Only categories
    """
    config_stub.val.url.searchengines = {
        "DEFAULT": "https://duckduckgo.com/?q={}",
        "google": "https://google.com/?q={}"
    }
    config_stub.val.completion.open_categories = []
    model = urlmodel.url(info=info)
    model.set_pattern('')
    qtmodeltester.data_display_may_return_none = True
    qtmodeltester.check(model)

    _check_completions(model, {})
예제 #17
0
def test_url_completion_no_quickmarks(qtmodeltester, web_history_populated,
                                      quickmark_manager_stub, bookmarks, info):
    """Test that the quickmark category is gone with no quickmarks."""
    model = urlmodel.url(info=info)
    model.set_pattern('')
    qtmodeltester.check(model)

    _check_completions(model, {
        "Bookmarks": [
            ('https://github.com', 'GitHub', None),
            ('https://python.org', 'Welcome to Python.org', None),
            ('http://qutebrowser.org', 'qutebrowser | qutebrowser', None),
        ],
        "History": [
            ('https://github.com', 'https://github.com', '2016-05-01'),
            ('https://python.org', 'Welcome to Python.org', '2016-03-08'),
            ('http://qutebrowser.org', 'qutebrowser', '2015-09-05'),
        ],
    })
예제 #18
0
def test_url_completion_no_bookmarks(qtmodeltester, web_history_populated,
                                     quickmarks, bookmark_manager_stub, info):
    """Test that the bookmarks category is gone with no bookmarks."""
    model = urlmodel.url(info=info)
    model.set_pattern('')
    qtmodeltester.check(model)

    _check_completions(model, {
        "Quickmarks": [
            ('https://wiki.archlinux.org', 'aw', None),
            ('https://wikipedia.org', 'wiki', None),
            ('https://duckduckgo.com', 'ddg', None),
        ],
        "History": [
            ('https://github.com', 'https://github.com', '2016-05-01'),
            ('https://python.org', 'Welcome to Python.org', '2016-03-08'),
            ('http://qutebrowser.org', 'qutebrowser', '2015-09-05'),
        ],
    })
def test_url_completion_delete_history(qtmodeltester, info,
                                       web_history_populated, quickmarks,
                                       bookmarks):
    """Test deleting a history entry."""
    model = urlmodel.url(info=info)
    model.set_pattern('')
    qtmodeltester.data_display_may_return_none = True
    qtmodeltester.check(model)

    parent = model.index(2, 0)
    idx = model.index(1, 0, parent)

    # sanity checks
    assert model.data(parent) == "History"
    assert model.data(idx) == 'https://python.org'

    assert 'https://python.org' in web_history_populated
    model.delete_cur_item(idx)
    assert 'https://python.org' not in web_history_populated
예제 #20
0
def test_url_completion_delete_quickmark(qtmodeltester, info, qtbot,
                                         quickmarks, web_history, bookmarks):
    """Test deleting a bookmark from the url completion model."""
    model = urlmodel.url(info=info)
    model.set_pattern('')
    qtmodeltester.check(model)

    parent = model.index(0, 0)
    idx = model.index(0, 0, parent)

    # sanity checks
    assert model.data(parent) == "Quickmarks"
    assert model.data(idx) == 'https://wiki.archlinux.org'
    assert 'ddg' in quickmarks.marks

    len_before = len(quickmarks.marks)
    model.delete_cur_item(idx)
    assert 'aw' not in quickmarks.marks
    assert len_before == len(quickmarks.marks) + 1
예제 #21
0
def test_url_completion_delete_bookmark(qtmodeltester, bookmarks, web_history,
                                        quickmarks, info):
    """Test deleting a bookmark from the url completion model."""
    model = urlmodel.url(info=info)
    model.set_pattern('')
    qtmodeltester.check(model)

    parent = model.index(1, 0)
    idx = model.index(1, 0, parent)

    # sanity checks
    assert model.data(parent) == "Bookmarks"
    assert model.data(idx) == 'https://python.org'
    assert 'https://github.com' in bookmarks.marks

    len_before = len(bookmarks.marks)
    model.delete_cur_item(idx)
    assert 'https://python.org' not in bookmarks.marks
    assert len_before == len(bookmarks.marks) + 1
예제 #22
0
def test_open_categories(qtmodeltester, config_stub, web_history_populated,
                         quickmarks, bookmarks, info):
    """Test that the open_categories setting has the desired effect.

    Verify that:
        - All categories are listed when they are defined in the
          completion.open_categories list.
    """
    config_stub.val.url.searchengines = {
        "DEFAULT": "https://duckduckgo.com/?q={}",
        "google": "https://google.com/?q={}",
    }
    config_stub.val.completion.open_categories = [
        "searchengines",
        "quickmarks",
        "bookmarks",
        "history",
    ]
    model = urlmodel.url(info=info)
    model.set_pattern('')
    qtmodeltester.check(model)

    _check_completions(
        model, {
            "Search engines": [
                ('google', 'https://google.com/?q={}', None),
            ],
            "Quickmarks": [
                ('https://wiki.archlinux.org', 'aw', None),
                ('https://wikipedia.org', 'wiki', None),
                ('https://duckduckgo.com', 'ddg', None),
            ],
            "Bookmarks": [
                ('https://github.com', 'GitHub', None),
                ('https://python.org', 'Welcome to Python.org', None),
                ('http://qutebrowser.org', 'qutebrowser | qutebrowser', None),
            ],
            "History": [
                ('https://github.com', 'https://github.com', '2016-05-01'),
                ('https://python.org', 'Welcome to Python.org', '2016-03-08'),
                ('http://qutebrowser.org', 'qutebrowser', '2015-09-05'),
            ],
        })
예제 #23
0
def test_open_categories(qtmodeltester, config_stub, web_history_populated,
                         quickmarks, bookmarks, info):
    """Test that the open_categories setting has the desired effect.

    Verify that:
        - All categories are listed when they are defined in the
          completion.open_categories list.
    """
    config_stub.val.url.searchengines = {
        "DEFAULT": "https://duckduckgo.com/?q={}",
        "google": "https://google.com/?q={}",
    }
    config_stub.val.completion.open_categories = [
        "searchengines",
        "quickmarks",
        "bookmarks",
        "history",
    ]
    model = urlmodel.url(info=info)
    model.set_pattern('')
    qtmodeltester.check(model)

    _check_completions(model, {
        "Search engines": [
            ('google', 'https://google.com/?q={}', None),
        ],
        "Quickmarks": [
            ('https://wiki.archlinux.org', 'aw', None),
            ('https://wikipedia.org', 'wiki', None),
            ('https://duckduckgo.com', 'ddg', None),
        ],
        "Bookmarks": [
            ('https://github.com', 'GitHub', None),
            ('https://python.org', 'Welcome to Python.org', None),
            ('http://qutebrowser.org', 'qutebrowser | qutebrowser', None),
        ],
        "History": [
            ('https://github.com', 'https://github.com', '2016-05-01'),
            ('https://python.org', 'Welcome to Python.org', '2016-03-08'),
            ('http://qutebrowser.org', 'qutebrowser', '2015-09-05'),
        ],
    })
예제 #24
0
def test_url_completion_delete_quickmark(qtmodeltester, quickmarks,
                                         web_history, bookmarks, qtbot):
    """Test deleting a bookmark from the url completion model."""
    model = urlmodel.url()
    model.set_pattern('')
    qtmodeltester.data_display_may_return_none = True
    qtmodeltester.check(model)

    parent = model.index(0, 0)
    idx = model.index(0, 0, parent)

    # sanity checks
    assert model.data(parent) == "Quickmarks"
    assert model.data(idx) == 'https://duckduckgo.com'
    assert 'ddg' in quickmarks.marks

    len_before = len(quickmarks.marks)
    model.delete_cur_item(idx)
    assert 'ddg' not in quickmarks.marks
    assert len_before == len(quickmarks.marks) + 1
예제 #25
0
def test_open_categories_remove_one(qtmodeltester, config_stub,
                                    web_history_populated, quickmarks,
                                    bookmarks, info):
    """Test that removing an item (boookmarks) from the open_categories settings has the desired effect.

    Verify that:
        - Only categories
    """
    config_stub.val.url.searchengines = {
        "DEFAULT": "https://duckduckgo.com/?q={}",
        "google": "https://google.com/?q={}"
    }
    config_stub.val.completion.open_categories = [
        "searchengines", "quickmarks", "history"
    ]
    model = urlmodel.url(info=info)
    model.set_pattern('')
    qtmodeltester.data_display_may_return_none = True
    qtmodeltester.check(model)

    _check_completions(
        model, {
            "Search engines": [
                ('google', 'https://google.com/?q={}', None),
            ],
            "Quickmarks": [
                ('https://wiki.archlinux.org', 'aw', None),
                ('https://wikipedia.org', 'wiki', None),
                ('https://duckduckgo.com', 'ddg', None),
            ],
            "History": [
                ('https://github.com', 'https://github.com', '2016-05-01'),
                ('https://python.org', 'Welcome to Python.org', '2016-03-08'),
                ('http://qutebrowser.org', 'qutebrowser', '2015-09-05'),
            ],
        })
예제 #26
0
def test_search_only_default(qtmodeltester, config_stub, web_history_populated,
                             quickmarks, bookmarks, info):
    """Test that Seardh engines is not shown when only default search engine is set in settings.

    Verify that:
        - No Search engines categories is shown
    """
    config_stub.val.completion.open_categories = [
        "searchengines", "quickmarks", "bookmarks", "history"
    ]
    config_stub.val.url.searchengines = {
        "DEFAULT": "https://duckduckgo.com/?q={}",
    }
    model = urlmodel.url(info=info)
    model.set_pattern('')
    qtmodeltester.data_display_may_return_none = True
    qtmodeltester.check(model)

    _check_completions(
        model, {
            "Quickmarks": [
                ('https://wiki.archlinux.org', 'aw', None),
                ('https://wikipedia.org', 'wiki', None),
                ('https://duckduckgo.com', 'ddg', None),
            ],
            "Bookmarks": [
                ('https://github.com', 'GitHub', None),
                ('https://python.org', 'Welcome to Python.org', None),
                ('http://qutebrowser.org', 'qutebrowser | qutebrowser', None),
            ],
            "History": [
                ('https://github.com', 'https://github.com', '2016-05-01'),
                ('https://python.org', 'Welcome to Python.org', '2016-03-08'),
                ('http://qutebrowser.org', 'qutebrowser', '2015-09-05'),
            ],
        })