diff options
author | Thorsten Wißmann <edu@thorsten-wissmann.de> | 2020-04-16 18:35:52 +0200 |
---|---|---|
committer | Thorsten Wißmann <edu@thorsten-wissmann.de> | 2020-04-16 18:35:52 +0200 |
commit | dfbff606252101d3a8ec8fdf1efa1693878a5341 (patch) | |
tree | e35b0dae3040090c1116f1d44f339b6100ba82ff | |
parent | 6e32a8dc07845590c290e56de687fdab9e485a9e (diff) | |
download | qutebrowser-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.py | 20 |
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&', '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'), |