qutebrowser/tests/end2end/features/test_prompts_bdd.py

74 lines
2.4 KiB
Python
Raw Normal View History

# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
2017-05-09 21:37:03 +02:00
# Copyright 2016-2017 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
#
# 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 <http://www.gnu.org/licenses/>.
import pytest_bdd as bdd
2016-01-12 08:20:08 +01:00
bdd.scenarios('prompts.feature')
@bdd.when("I load an SSL page")
2016-01-12 23:21:52 +01:00
def load_ssl_page(quteproc, ssl_server):
# We don't wait here as we can get an SSL question.
quteproc.open_path('/', port=ssl_server.port, https=True, wait=False)
2016-01-12 23:21:52 +01:00
@bdd.when("I wait until the SSL page finished loading")
2016-01-13 06:41:22 +01:00
def wait_ssl_page_finished_loading(quteproc, ssl_server):
2016-01-12 23:21:52 +01:00
quteproc.wait_for_load_finished('/', port=ssl_server.port, https=True,
load_status='warn')
2016-01-13 21:45:34 +01:00
@bdd.when("I wait for a prompt")
def wait_for_prompt(quteproc):
2016-10-27 09:16:19 +02:00
quteproc.wait_for(message='Asking question *')
2016-01-13 22:36:27 +01:00
2016-01-13 22:36:27 +01:00
@bdd.then("no prompt should be shown")
def no_prompt_shown(quteproc):
quteproc.ensure_not_logged(message='Entering mode KeyMode.* (reason: '
'question asked)')
2016-11-10 10:26:27 +01:00
@bdd.then("a SSL error page should be shown")
def ssl_error_page(request, quteproc):
if not request.config.webengine:
line = quteproc.wait_for(message='Error while loading *: SSL '
'handshake failed')
line.expected = True
quteproc.wait_for(message="Changing title for idx * to 'Error "
"loading page: *'")
content = quteproc.get_content().strip()
assert "Unable to load page" in content
2016-11-10 13:53:13 +01:00
class AbstractCertificateErrorWrapper:
"""A wrapper over an SSL/certificate error."""
def __init__(self, error):
self._error = error
def __str__(self):
raise NotImplementedError
def __repr__(self):
raise NotImplementedError
def is_overridable(self):
raise NotImplementedError