From 230cd40b12f6fff4137421a88ecadcb0998a0a8e Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 9 Sep 2016 18:43:56 +0200 Subject: [PATCH] Add a test for a misconfigured XDG_DOWNLOAD_DIR See #866 and #1269. --- tests/end2end/test_invocations.py | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/end2end/test_invocations.py b/tests/end2end/test_invocations.py index 6e49995ef..b79726fbf 100644 --- a/tests/end2end/test_invocations.py +++ b/tests/end2end/test_invocations.py @@ -20,6 +20,7 @@ """Test starting qutebrowser with special arguments/environments.""" import sys +import logging import pytest @@ -115,6 +116,42 @@ def test_ascii_locale(request, httpbin, tmpdir, quteproc_new): assert (tmpdir / '?-issue908.bin').exists() +@pytest.mark.linux +def test_misconfigured_user_dirs(request, httpbin, temp_basedir_env, + tmpdir, quteproc_new): + """Test downloads with a misconfigured XDG_DOWNLOAD_DIR + + https://github.com/The-Compiler/qutebrowser/issues/866 + https://github.com/The-Compiler/qutebrowser/issues/1269 + """ + if request.config.webengine: + pytest.skip("Downloads are not implemented with QtWebEngine yet") + + home = tmpdir / 'home' + home.ensure(dir=True) + temp_basedir_env['HOME'] = str(home) + + assert temp_basedir_env['XDG_CONFIG_HOME'] == tmpdir / 'config' + (tmpdir / 'config' / 'user-dirs.dirs').write('XDG_DOWNLOAD_DIR="relative"', + ensure=True) + + quteproc_new.start(_base_args(request.config), env=temp_basedir_env) + + quteproc_new.set_setting('storage', 'prompt-download-directory', 'false') + url = 'http://localhost:{port}/data/downloads/download.bin'.format( + port=httpbin.port) + quteproc_new.send_cmd(':download {}'.format(url)) + line = quteproc_new.wait_for( + loglevel=logging.ERROR, category='message', + message='XDG_DOWNLOAD_DIR points to a relative path - please check ' + 'your ~/.config/user-dirs.dirs. The download is saved in your ' + 'home directory.') + line.expected = True + quteproc_new.wait_for(category='downloads', message='Download finished') + + assert (home / 'download.bin').exists() + + def test_no_loglines(request, quteproc_new): """Test qute:log with --loglines=0.""" if request.config.webengine: