From 0daf5885be3b8dd18e98b5762ff5911387b3a79b Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 9 Nov 2015 07:49:11 +0100 Subject: [PATCH] Add some BDD tests for downloads. --- tests/integration/data/downloads/download.bin | Bin 0 -> 1 bytes .../integration/data/downloads/issue889.html | 11 +++++ tests/integration/features/downloads.feature | 44 ++++++++++++++++++ tests/integration/features/test_downloads.py | 26 +++++++++++ 4 files changed, 81 insertions(+) create mode 100644 tests/integration/data/downloads/download.bin create mode 100644 tests/integration/data/downloads/issue889.html create mode 100644 tests/integration/features/downloads.feature create mode 100644 tests/integration/features/test_downloads.py diff --git a/tests/integration/data/downloads/download.bin b/tests/integration/data/downloads/download.bin new file mode 100644 index 0000000000000000000000000000000000000000..f76dd238ade08917e6712764a16a22005a50573d GIT binary patch literal 1 IcmZPo000310RR91 literal 0 HcmV?d00001 diff --git a/tests/integration/data/downloads/issue889.html b/tests/integration/data/downloads/issue889.html new file mode 100644 index 000000000..f6dbcfcbd --- /dev/null +++ b/tests/integration/data/downloads/issue889.html @@ -0,0 +1,11 @@ + + + + + Failing download when redirecting/aborting + + + redirect after 1s + 404 + + diff --git a/tests/integration/features/downloads.feature b/tests/integration/features/downloads.feature new file mode 100644 index 000000000..f81b5677d --- /dev/null +++ b/tests/integration/features/downloads.feature @@ -0,0 +1,44 @@ +Feature: Downloading things from a website. + + Background: + Given I set storage -> prompt-download-directory to false + And I run :download-clear + + Scenario: Downloading which redirects with closed tab (issue 889) + When I set tabs -> last-close to blank + And I open data/downloads/issue889.html + And I run :hint links download + And I run :follow-hint a + And I run :tab-close + And I wait for "* Handling redirect" in the log + Then no crash should happen + + Scenario: Downloading with error in closed tab (issue 889) + When I set tabs -> last-close to blank + And I open data/downloads/issue889.html + And I run :hint links download + And I run :follow-hint s + And I run :tab-close + And I wait for the error "Download error: * - server replied: NOT FOUND" + And I run :download-retry + And I wait for the error "Download error: * - server replied: NOT FOUND" + Then no crash should happen + + Scenario: Retrying a failed download + When I run :download http://localhost:(port)/does-not-exist + And I wait for the error "Download error: * - server replied: NOT FOUND" + And I run :download-retry + And I wait for the error "Download error: * - server replied: NOT FOUND" + Then the requests should be: + does-not-exist + does-not-exist + + Scenario: Retrying with no failed downloads + When I open data/downloads/download.bin + And I wait until the download is finished + And I run :download-retry + Then the error "No failed downloads!" should be shown. + + Scenario: Retrying with no downloads + When I run :download-retry + Then the error "No failed downloads!" should be shown. diff --git a/tests/integration/features/test_downloads.py b/tests/integration/features/test_downloads.py new file mode 100644 index 000000000..d202c53ce --- /dev/null +++ b/tests/integration/features/test_downloads.py @@ -0,0 +1,26 @@ +# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: + +# Copyright 2015 Florian Bruhin (The Compiler) +# +# This file is part of qutebrowser. +# +# qutebrowser is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# qutebrowser is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with qutebrowser. If not, see . + +import pytest_bdd as bdd +bdd.scenarios('downloads.feature') + + +@bdd.when("I wait until the download is finished") +def wait_for_download_finished(quteproc): + quteproc.wait_for(category='downloads', message='Download finished')