add tests for download-open/prompt-open-download

This has tests for
* standard :download-open
* standard :prompt-open-download
* :prompt-open-download + cancel the download (issue #1728)
This commit is contained in:
Daniel Schadt 2016-08-03 17:55:52 +02:00
parent e8bfc25bbc
commit afa7494c5f
2 changed files with 35 additions and 5 deletions

View File

@ -158,11 +158,11 @@ Feature: Downloading things from a website.
## :download-open
# Scenario: Opening a download
# When I open data/downloads/download.bin
# And I wait until the download is finished
# And I run :download-open
# Then ...
Scenario: Opening a download
When I open data/downloads/download.bin
And I wait until the download is finished
And I open the download
Then "Opening *download.bin* with [*python*]" should be logged
Scenario: Opening a download which does not exist
When I run :download-open with count 42
@ -178,6 +178,24 @@ 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
## opening a file directly (prompt-open-download)
Scenario: Opening a download directly
When I set storage -> prompt-download-directory to true
And I open data/downloads/download.bin
And I directly open the download
And I wait until the download is finished
Then "Opening *download.bin* with [*python*]" should be logged
## https://github.com/The-Compiler/qutebrowser/issues/1728
Scenario: Cancelling a download that should be opened
When I set storage -> prompt-download-directory to true
And I run :download http://localhost:(port)/drip?numbytes=128&duration=5
And I directly open the download
And I run :download-cancel
Then "* finished but not successful, not opening!" should be logged
## completion -> download-path-suggestion
Scenario: completion -> download-path-suggestion = path

View File

@ -18,6 +18,7 @@
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
import os
import sys
import pytest_bdd as bdd
bdd.scenarios('downloads.feature')
@ -68,3 +69,14 @@ def download_prompt(tmpdir, quteproc, path):
"text='Save file to:'>, *".format(full_path=full_path))
quteproc.wait_for(message=msg)
quteproc.send_cmd(':leave-mode')
@bdd.when("I open the download")
def download_open(quteproc):
cmd = '"{}" -c pass'.format(sys.executable)
quteproc.send_cmd(':download-open {}'.format(cmd))
@bdd.when("I directly open the download")
def download_open(quteproc):
cmd = '"{}" -c pass'.format(sys.executable)
quteproc.send_cmd(':prompt-open-download {}'.format(cmd))