summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorsten Wißmann <edu@thorsten-wissmann.de>2020-04-16 18:35:52 +0200
committerThorsten Wißmann <edu@thorsten-wissmann.de>2020-04-16 18:35:52 +0200
commitdfbff606252101d3a8ec8fdf1efa1693878a5341 (patch)
treee35b0dae3040090c1116f1d44f339b6100ba82ff
parent6e32a8dc07845590c290e56de687fdab9e485a9e (diff)
downloadqutebrowser-dfbff606252101d3a8ec8fdf1efa1693878a5341.tar.gz
qutebrowser-dfbff606252101d3a8ec8fdf1efa1693878a5341.zip
Fix test_get_search_url()
This also adds a test-case for the 'path-search' search engine defined in the config_stub.
-rw-r--r--tests/unit/utils/test_urlutils.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/unit/utils/test_urlutils.py b/tests/unit/utils/test_urlutils.py
index 541deee78..39a43479b 100644
--- a/tests/unit/utils/test_urlutils.py
+++ b/tests/unit/utils/test_urlutils.py
@@ -291,7 +291,6 @@ def test_special_urls(url, special):
('test/with/slashes', 'www.example.com', 'q=test/with/slashes'),
('test path-search', 'www.qutebrowser.org', 'q=path-search'),
('slash/and&amp', 'www.example.com', 'q=slash/and%26amp'),
- ('quoted-path t/w/s', 'www.example.org', 't%26w%26s'),
('unquoted one=1&two=2', 'www.example.org', 'one=1&two=2'),
])
def test_get_search_url(config_stub, url, host, query, open_base_url):
@@ -308,6 +307,25 @@ def test_get_search_url(config_stub, url, host, query, open_base_url):
assert url.query() == query
+@pytest.mark.parametrize('open_base_url', [True, False])
+@pytest.mark.parametrize('url, host, path', [
+ ('path-search t/w/s', 'www.example.org', 't/w/s'),
+ ('quoted-path t/w/s', 'www.example.org', 't%2Fw%2Fs'),
+])
+def test_get_search_url_for_path_search(config_stub, url, host, path, open_base_url):
+ """Test _get_search_url_for_path_search().
+
+ Args:
+ url: The "URL" to enter.
+ host: The expected search machine host.
+ path: The expected path on that host that is requested.
+ """
+ config_stub.val.url.open_base_url = open_base_url
+ url = urlutils._get_search_url(url)
+ assert url.host() == host
+ assert url.path(options=QUrl.PrettyDecoded) == '/' + path
+
+
@pytest.mark.parametrize('url, host', [
('test', 'www.qutebrowser.org'),
('test-with-dash', 'www.example.org'),