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://glimpsebrowser.org', 'glimpsebrowser | glimpsebrowser', None), ], "History": [ ('https://github.com', 'https://github.com', '2016-05-01'), ('https://python.org', 'Welcome to Python.org', '2016-03-08'), ('http://glimpsebrowser.org', 'glimpsebrowser', '2015-09-05'), ], })
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://glimpsebrowser.org', 'glimpsebrowser', '2015-09-05'), ], })
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(0, 0)) == rowcount
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')
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, {})
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
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
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://glimpsebrowser.org', 'glimpsebrowser | glimpsebrowser', None), ], "History": [ ('https://github.com', 'https://github.com', '2016-05-01'), ('https://python.org', 'Welcome to Python.org', '2016-03-08'), ('http://glimpsebrowser.org', 'glimpsebrowser', '2015-09-05'), ], })
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
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
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://glimpsebrowser.org', 'glimpsebrowser', '2015-09-05'), ], })
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://glimpsebrowser.org', 'glimpsebrowser | glimpsebrowser', None), ], "History": [ ('https://github.com', 'https://github.com', '2016-05-01'), ('https://python.org', 'Welcome to Python.org', '2016-03-08'), ('http://glimpsebrowser.org', 'glimpsebrowser', '2015-09-05'), ], })
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://glimpsebrowser.org', 'glimpsebrowser | glimpsebrowser', None), ], "History": [ ('https://github.com', 'https://github.com', '2016-05-01'), ('https://python.org', 'Welcome to Python.org', '2016-03-08'), ('http://glimpsebrowser.org', 'glimpsebrowser', '2015-09-05'), ], })