Use a tmpdir subdir for download BDD tests
This commit is contained in:
parent
5ede2c6417
commit
2f3e671578
@ -184,7 +184,7 @@ Feature: Downloading things from a website.
|
|||||||
Then the error "Can only download the current page as mhtml." should be shown
|
Then the error "Can only download the current page as mhtml." should be shown
|
||||||
|
|
||||||
Scenario: :download with a directory which doesn't exist
|
Scenario: :download with a directory which doesn't exist
|
||||||
When I run :download --dest (tmpdir)/somedir/filename http://localhost:(port)/
|
When I run :download --dest (tmpdir)/downloads/somedir/filename http://localhost:(port)/
|
||||||
Then the error "Download error: No such file or directory" should be shown
|
Then the error "Download error: No such file or directory" should be shown
|
||||||
|
|
||||||
## mhtml downloads
|
## mhtml downloads
|
||||||
@ -402,7 +402,7 @@ Feature: Downloading things from a website.
|
|||||||
When I set storage -> prompt-download-directory to true
|
When I set storage -> prompt-download-directory to true
|
||||||
And I set completion -> download-path-suggestion to path
|
And I set completion -> download-path-suggestion to path
|
||||||
And I open data/downloads/download.bin without waiting
|
And I open data/downloads/download.bin without waiting
|
||||||
Then the download prompt should be shown with "(tmpdir)/"
|
Then the download prompt should be shown with "(tmpdir)/downloads/"
|
||||||
|
|
||||||
Scenario: completion -> download-path-suggestion = filename
|
Scenario: completion -> download-path-suggestion = filename
|
||||||
When I set storage -> prompt-download-directory to true
|
When I set storage -> prompt-download-directory to true
|
||||||
@ -414,7 +414,7 @@ Feature: Downloading things from a website.
|
|||||||
When I set storage -> prompt-download-directory to true
|
When I set storage -> prompt-download-directory to true
|
||||||
And I set completion -> download-path-suggestion to both
|
And I set completion -> download-path-suggestion to both
|
||||||
And I open data/downloads/download.bin without waiting
|
And I open data/downloads/download.bin without waiting
|
||||||
Then the download prompt should be shown with "(tmpdir)/download.bin"
|
Then the download prompt should be shown with "(tmpdir)/downloads/download.bin"
|
||||||
|
|
||||||
## storage -> remember-download-directory
|
## storage -> remember-download-directory
|
||||||
|
|
||||||
@ -424,19 +424,19 @@ Feature: Downloading things from a website.
|
|||||||
And I set storage -> remember-download-directory to true
|
And I set storage -> remember-download-directory to true
|
||||||
And I open data/downloads/download.bin without waiting
|
And I open data/downloads/download.bin without waiting
|
||||||
And I wait for the download prompt for "*/download.bin"
|
And I wait for the download prompt for "*/download.bin"
|
||||||
And I run :prompt-accept (tmpdir)(dirsep)subdir
|
And I run :prompt-accept (tmpdir)(dirsep)downloads(dirsep)subdir
|
||||||
And I open data/downloads/download2.bin without waiting
|
And I open data/downloads/download2.bin without waiting
|
||||||
Then the download prompt should be shown with "(tmpdir)/subdir/download2.bin"
|
Then the download prompt should be shown with "(tmpdir)/downloads/subdir/download2.bin"
|
||||||
|
|
||||||
Scenario: Not remembering the last download directory
|
Scenario: Not remembering the last download directory
|
||||||
When I set storage -> prompt-download-directory to true
|
When I set storage -> prompt-download-directory to true
|
||||||
And I set completion -> download-path-suggestion to both
|
And I set completion -> download-path-suggestion to both
|
||||||
And I set storage -> remember-download-directory to false
|
And I set storage -> remember-download-directory to false
|
||||||
And I open data/downloads/download.bin without waiting
|
And I open data/downloads/download.bin without waiting
|
||||||
And I wait for the download prompt for "(tmpdir)/download.bin"
|
And I wait for the download prompt for "(tmpdir)/downloads/download.bin"
|
||||||
And I run :prompt-accept (tmpdir)(dirsep)subdir
|
And I run :prompt-accept (tmpdir)(dirsep)downloads(dirsep)subdir
|
||||||
And I open data/downloads/download2.bin without waiting
|
And I open data/downloads/download2.bin without waiting
|
||||||
Then the download prompt should be shown with "(tmpdir)/download2.bin"
|
Then the download prompt should be shown with "(tmpdir)/downloads/download2.bin"
|
||||||
|
|
||||||
# https://github.com/The-Compiler/qutebrowser/issues/2173
|
# https://github.com/The-Compiler/qutebrowser/issues/2173
|
||||||
|
|
||||||
@ -446,12 +446,12 @@ Feature: Downloading things from a website.
|
|||||||
And I set storage -> remember-download-directory to true
|
And I set storage -> remember-download-directory to true
|
||||||
And I open data/downloads/download.bin without waiting
|
And I open data/downloads/download.bin without waiting
|
||||||
And I wait for the download prompt for "*"
|
And I wait for the download prompt for "*"
|
||||||
And I run :prompt-accept (tmpdir)
|
And I run :prompt-accept (tmpdir)/downloads
|
||||||
And I open data/downloads/download.bin without waiting
|
And I open data/downloads/download.bin without waiting
|
||||||
And I wait for the download prompt for "*"
|
And I wait for the download prompt for "*"
|
||||||
And I directly open the download
|
And I directly open the download
|
||||||
And I open data/downloads/download.bin without waiting
|
And I open data/downloads/download.bin without waiting
|
||||||
Then the download prompt should be shown with "(tmpdir)/download.bin"
|
Then the download prompt should be shown with "(tmpdir)/downloads/download.bin"
|
||||||
|
|
||||||
# Overwriting files
|
# Overwriting files
|
||||||
|
|
||||||
@ -520,7 +520,7 @@ Feature: Downloading things from a website.
|
|||||||
@posix
|
@posix
|
||||||
Scenario: Downloading to unwritable destination
|
Scenario: Downloading to unwritable destination
|
||||||
When I set storage -> prompt-download-directory to false
|
When I set storage -> prompt-download-directory to false
|
||||||
And I run :download http://localhost:(port)/data/downloads/download.bin --dest (tmpdir)/unwritable
|
And I run :download http://localhost:(port)/data/downloads/download.bin --dest (tmpdir)/downloads/unwritable
|
||||||
Then the error "Download error: Permission denied" should be shown
|
Then the error "Download error: Permission denied" should be shown
|
||||||
|
|
||||||
Scenario: Downloading 20MB file
|
Scenario: Downloading 20MB file
|
||||||
|
@ -32,15 +32,17 @@ PROMPT_MSG = ("Asking question <qutebrowser.utils.usertypes.Question "
|
|||||||
|
|
||||||
@bdd.given("I set up a temporary download dir")
|
@bdd.given("I set up a temporary download dir")
|
||||||
def temporary_download_dir(quteproc, tmpdir):
|
def temporary_download_dir(quteproc, tmpdir):
|
||||||
|
download_dir = tmpdir / 'downloads'
|
||||||
|
download_dir.ensure(dir=True)
|
||||||
quteproc.set_setting('storage', 'prompt-download-directory', 'false')
|
quteproc.set_setting('storage', 'prompt-download-directory', 'false')
|
||||||
quteproc.set_setting('storage', 'remember-download-directory', 'false')
|
quteproc.set_setting('storage', 'remember-download-directory', 'false')
|
||||||
quteproc.set_setting('storage', 'download-directory', str(tmpdir))
|
quteproc.set_setting('storage', 'download-directory', str(download_dir))
|
||||||
(tmpdir / 'subdir').ensure(dir=True)
|
(download_dir / 'subdir').ensure(dir=True)
|
||||||
try:
|
try:
|
||||||
os.mkfifo(str(tmpdir / 'fifo'))
|
os.mkfifo(str(download_dir / 'fifo'))
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
unwritable = tmpdir / 'unwritable'
|
unwritable = download_dir / 'unwritable'
|
||||||
unwritable.ensure(dir=True)
|
unwritable.ensure(dir=True)
|
||||||
unwritable.chmod(0)
|
unwritable.chmod(0)
|
||||||
|
|
||||||
@ -76,20 +78,20 @@ def download_ssl_page(quteproc, ssl_server):
|
|||||||
|
|
||||||
@bdd.then(bdd.parsers.parse("The downloaded file {filename} should not exist"))
|
@bdd.then(bdd.parsers.parse("The downloaded file {filename} should not exist"))
|
||||||
def download_should_not_exist(filename, tmpdir):
|
def download_should_not_exist(filename, tmpdir):
|
||||||
path = tmpdir / filename
|
path = tmpdir / 'downloads' / filename
|
||||||
assert not path.check()
|
assert not path.check()
|
||||||
|
|
||||||
|
|
||||||
@bdd.then(bdd.parsers.parse("The downloaded file {filename} should exist"))
|
@bdd.then(bdd.parsers.parse("The downloaded file {filename} should exist"))
|
||||||
def download_should_exist(filename, tmpdir):
|
def download_should_exist(filename, tmpdir):
|
||||||
path = tmpdir / filename
|
path = tmpdir / 'downloads' / filename
|
||||||
assert path.check()
|
assert path.check()
|
||||||
|
|
||||||
|
|
||||||
@bdd.then(bdd.parsers.parse("The downloaded file {filename} should contain "
|
@bdd.then(bdd.parsers.parse("The downloaded file {filename} should contain "
|
||||||
"{size} bytes"))
|
"{size} bytes"))
|
||||||
def download_size(filename, size, tmpdir):
|
def download_size(filename, size, tmpdir):
|
||||||
path = tmpdir / filename
|
path = tmpdir / 'downloads' / filename
|
||||||
assert path.size() == int(size)
|
assert path.size() == int(size)
|
||||||
|
|
||||||
|
|
||||||
@ -130,9 +132,11 @@ def download_open_with_prompt(quteproc):
|
|||||||
|
|
||||||
@bdd.when(bdd.parsers.parse("I delete the downloaded file {filename}"))
|
@bdd.when(bdd.parsers.parse("I delete the downloaded file {filename}"))
|
||||||
def delete_file(tmpdir, filename):
|
def delete_file(tmpdir, filename):
|
||||||
(tmpdir / filename).remove()
|
(tmpdir / 'downloads' / filename).remove()
|
||||||
|
|
||||||
|
|
||||||
@bdd.then("the FIFO should still be a FIFO")
|
@bdd.then("the FIFO should still be a FIFO")
|
||||||
def fifo_should_be_fifo(tmpdir):
|
def fifo_should_be_fifo(tmpdir):
|
||||||
assert tmpdir.exists() and not os.path.isfile(str(tmpdir / 'fifo'))
|
download_dir = tmpdir / 'downloads'
|
||||||
|
assert download_dir.exists()
|
||||||
|
assert not os.path.isfile(str(download_dir / 'fifo'))
|
||||||
|
Loading…
Reference in New Issue
Block a user