2015-11-10 06:33:47 +01:00
|
|
|
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
|
|
|
|
2016-01-04 07:12:39 +01:00
|
|
|
# Copyright 2015-2016 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
2015-11-10 06:33:47 +01:00
|
|
|
#
|
|
|
|
# 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/>.
|
|
|
|
|
2016-01-04 20:10:03 +01:00
|
|
|
import sys
|
2016-06-08 16:34:42 +02:00
|
|
|
import json
|
2016-01-04 20:10:03 +01:00
|
|
|
import os.path
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
import pytest
|
2015-11-10 06:33:47 +01:00
|
|
|
import pytest_bdd as bdd
|
2016-01-04 20:10:03 +01:00
|
|
|
|
|
|
|
import qutebrowser
|
|
|
|
from qutebrowser.utils import docutils
|
2015-12-20 20:00:56 +01:00
|
|
|
from qutebrowser.browser import pdfjs
|
|
|
|
|
2015-11-10 06:33:47 +01:00
|
|
|
bdd.scenarios('misc.feature')
|
2016-01-04 20:10:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
@bdd.when("the documentation is up to date")
|
|
|
|
def update_documentation():
|
|
|
|
"""Update the docs before testing :help."""
|
|
|
|
base_path = os.path.dirname(os.path.abspath(qutebrowser.__file__))
|
|
|
|
doc_path = os.path.join(base_path, 'html', 'doc')
|
|
|
|
script_path = os.path.join(base_path, '..', 'scripts')
|
|
|
|
|
2016-01-04 20:36:15 +01:00
|
|
|
if not os.path.exists(doc_path):
|
|
|
|
# On CI, we can test this without actually building the docs
|
|
|
|
return
|
|
|
|
|
|
|
|
if all(docutils.docs_up_to_date(p) for p in os.listdir(doc_path)):
|
|
|
|
return
|
2016-01-04 20:10:03 +01:00
|
|
|
|
|
|
|
try:
|
|
|
|
subprocess.call(['asciidoc'], stdout=subprocess.DEVNULL,
|
|
|
|
stderr=subprocess.DEVNULL)
|
|
|
|
except OSError:
|
|
|
|
pytest.skip("Docs outdated and asciidoc unavailable!")
|
|
|
|
|
|
|
|
update_script = os.path.join(script_path, 'asciidoc2html.py')
|
|
|
|
subprocess.call([sys.executable, update_script])
|
2016-01-05 07:21:26 +01:00
|
|
|
|
|
|
|
|
2015-12-20 20:00:56 +01:00
|
|
|
@bdd.given('pdfjs is available')
|
|
|
|
def pdfjs_available():
|
|
|
|
if not pdfjs.is_available():
|
|
|
|
pytest.skip("No pdfjs installation found.")
|
2016-06-08 16:34:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
@bdd.then(bdd.parsers.parse('the cookie {name} should be set to {value}'))
|
|
|
|
def check_cookie(quteproc, name, value):
|
|
|
|
"""Check if a given cookie is set correctly.
|
|
|
|
|
|
|
|
This assumes we're on the httpbin cookies page.
|
|
|
|
"""
|
|
|
|
content = quteproc.get_content()
|
|
|
|
data = json.loads(content)
|
|
|
|
print(data)
|
|
|
|
assert data['cookies'][name] == value
|
2016-07-12 02:08:24 +02:00
|
|
|
|
|
|
|
|
2016-07-12 13:28:43 +02:00
|
|
|
@bdd.then(bdd.parsers.parse('the PDF {filename} should exist in the tmpdir'))
|
|
|
|
def pdf_exists(quteproc, tmpdir, filename):
|
2016-07-12 02:08:24 +02:00
|
|
|
path = tmpdir / filename
|
2016-07-12 13:28:43 +02:00
|
|
|
data = path.read_binary()
|
|
|
|
assert data.startswith(b'%PDF')
|