From ebee06a9c4b0287b113d7e0cb55461dc357e423d Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 5 Apr 2016 11:42:42 +0200 Subject: [PATCH] bdd: Add tests for download-path-suggestion --- tests/integration/features/downloads.feature | 20 ++++++++++++++++++++ tests/integration/features/test_downloads.py | 12 ++++++++++++ 2 files changed, 32 insertions(+) diff --git a/tests/integration/features/downloads.feature b/tests/integration/features/downloads.feature index 8097711a5..fc401fe76 100644 --- a/tests/integration/features/downloads.feature +++ b/tests/integration/features/downloads.feature @@ -162,6 +162,26 @@ Feature: Downloading things from a website. And I run :download-open with count 1 Then the error "Download 1 is not done!" should be shown + ## completion -> download-path-suggestion + + Scenario: completion -> download-path-suggestion = path + When I set storage -> prompt-download-directory to true + And I set completion -> download-path-suggestion to path + And I open data/downloads/download.bin + Then the download prompt should be shown with "{downloaddir}/" + + Scenario: completion -> download-path-suggestion = filename + When I set storage -> prompt-download-directory to true + And I set completion -> download-path-suggestion to filename + And I open data/downloads/download.bin + Then the download prompt should be shown with "download.bin" + + Scenario: completion -> download-path-suggestion = both + When I set storage -> prompt-download-directory to true + And I set completion -> download-path-suggestion to both + And I open data/downloads/download.bin + Then the download prompt should be shown with "{downloaddir}/download.bin" + ## https://github.com/The-Compiler/qutebrowser/issues/1242 Scenario: Closing window with remove-finished-downloads timeout diff --git a/tests/integration/features/test_downloads.py b/tests/integration/features/test_downloads.py index 51613dc61..1ffbaf5b7 100644 --- a/tests/integration/features/test_downloads.py +++ b/tests/integration/features/test_downloads.py @@ -17,6 +17,8 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . +import os + import pytest_bdd as bdd bdd.scenarios('downloads.feature') @@ -49,3 +51,13 @@ def download_should_not_exist(filename, tmpdir): def download_should_exist(filename, tmpdir): path = tmpdir / filename assert path.check() + + +@bdd.then(bdd.parsers.parse('The download prompt should be shown with "{path}"')) +def download_prompt(tmpdir, quteproc, path): + full_path = path.replace('{downloaddir}', str(tmpdir)).replace('/', os.sep) + msg = ("Asking question " + "text='Save file to:'>, *".format(full_path=full_path)) + quteproc.wait_for(message=msg) + quteproc.send_cmd(':leave-mode')