bdd: Add tests for download-path-suggestion

This commit is contained in:
Florian Bruhin 2016-04-05 11:42:42 +02:00
parent 6c1ee07c85
commit ebee06a9c4
2 changed files with 32 additions and 0 deletions

View File

@ -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

View File

@ -17,6 +17,8 @@
# You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
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 <qutebrowser.utils.usertypes.Question "
"default='{full_path}' mode=<PromptMode.text: 2> "
"text='Save file to:'>, *".format(full_path=full_path))
quteproc.wait_for(message=msg)
quteproc.send_cmd(':leave-mode')