bdd: Add some more tests for downloads

This commit is contained in:
Florian Bruhin 2016-03-14 19:06:42 +01:00
parent 06190a0488
commit 41b6f68fd7
2 changed files with 86 additions and 0 deletions

View File

@ -87,3 +87,77 @@ Feature: Downloading things from a website.
And I run :download --mhtml --dest mhtml-response-headers.mht
And I wait for "File successfully written." in the log
Then no crash should happen
## :download-cancel
Scenario: Cancelling a download
When I run :download http://localhost:(port)/drip?numbytes=128&duration=5
And I run :download-cancel
Then "cancelled" should be logged
Scenario: Cancelling a download which does not exist
When I run :download-cancel with count 42
Then the error "There's no download 42!" should be shown
Scenario: Cancelling a download which is already done
When I open data/downloads/download.bin
And I wait until the download is finished
And I run :download-cancel
Then the error "Download 1 is already done!" should be shown
Scenario: Cancelling a download which is already done (with count)
When I open data/downloads/download.bin
And I wait until the download is finished
And I run :download-cancel with count 1
Then the error "Download 1 is already done!" should be shown
Scenario: Cancelling all downloads
When I run :download http://localhost:(port)/drip?numbytes=128&duration=5
And I run :download http://localhost:(port)/drip?numbytes=128&duration=5
And I run :download-cancel --all
Then "cancelled" should be logged
And "cancelled" should be logged
## :download-delete
Scenario: Deleting a download
When I open data/downloads/download.bin
And I wait until the download is finished
And I run :download-delete
Then the downloaded file download.bin should not exist
Scenario: Deleting a download which does not exist
When I run :download-delete with count 42
Then the error "There's no download 42!" should be shown
Scenario: Deleting a download which is not done yet
When I run :download http://localhost:(port)/drip?numbytes=128&duration=5
And I run :download-delete
Then the error "Download 1 is not done!" should be shown
Scenario: Deleting a download which is not done yet (with count)
When I run :download http://localhost:(port)/drip?numbytes=128&duration=5
And I run :download-delete with count 1
Then the error "Download 1 is not done!" should be shown
## :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 which does not exist
When I run :download-open with count 42
Then the error "There's no download 42!" should be shown
Scenario: Opening a download which is not done yet
When I run :download http://localhost:(port)/drip?numbytes=128&duration=5
And I run :download-open
Then the error "Download 1 is not done!" should be shown
Scenario: Opening a download which is not done yet (with count)
When I run :download http://localhost:(port)/drip?numbytes=128&duration=5
And I run :download-open with count 1
Then the error "Download 1 is not done!" should be shown

View File

@ -37,3 +37,15 @@ def clean_old_downloads(quteproc):
@bdd.when("I wait until the download is finished")
def wait_for_download_finished(quteproc):
quteproc.wait_for(category='downloads', message='Download finished')
@bdd.then(bdd.parsers.parse("The downloaded file {filename} should not exist"))
def download_should_not_exist(filename, tmpdir):
path = tmpdir / filename
assert not path.check()
@bdd.then(bdd.parsers.parse("The downloaded file {filename} should exist"))
def download_should_exist(filename, tmpdir):
path = tmpdir / filename
assert path.check()