Commit 347cd3d0 authored by Pascal's avatar Pascal
Browse files

cleanup tests

parent 7ded07da
[bdist_wheel]
universal=1
[tool:pytest]
addopts = -v
#addopts = -v
testpaths =
test
markers =
project
api
server
project = /Users/pascal/git/lektor-test-site/
branch =
lektor-admin-extra
......
......@@ -98,7 +98,6 @@ class BaseUrlSession(requests.Session):
"""Create the URL based off this partial path."""
return urljoin(self.base_url, url)
@pytest.fixture(scope='module')
def server(lektorproject, port):
......@@ -162,8 +161,12 @@ def draft(server):
yield session
session.close()
### API
@pytest.fixture(scope='module')
def project(request, lektorproject):
def project(lektorproject, branchname):
if branchname != 'lektor-admin-extra':
pytest.skip('already tested')
from lektor.project import Project
return Project.from_path(lektorproject)
......@@ -179,24 +182,23 @@ def pad(request, env):
@pytest.fixture(scope='module')
def webui(request, env):
from lektor.admin.webui import WebUI
output_path = tempfile.mkdtemp()
def cleanup():
try:
shutil.rmtree(output_path)
except (OSError, IOError):
pass
request.addfinalizer(cleanup)
return WebUI(env,
yield WebUI(env,
debug=True,
output_path=output_path)
try:
shutil.rmtree(output_path)
except (OSError, IOError):
pass
@pytest.fixture(scope='module')
def webclient(webui):
webui.config['TESTING'] = True
print('Starting up client')
with webui.test_client() as client:
yield client
print('Shutting down client')
import pytest
import os
@pytest.mark.project
def test_project(lektorproject):
print(lektorproject)
for (dirpath, dirnames, files) in os.walk(lektorproject):
......@@ -9,11 +10,13 @@ def test_project(lektorproject):
print(dirnames, files)
assert os.path.exists(os.path.join(lektorproject,'packages/lektor-admin-extra'))
@pytest.mark.api
def test_webclient_index(webclient):
rv = webclient.get('/')
print(rv.data)
assert b'<body>' in rv.data
@pytest.mark.api
def test_webclient_buttons(webclient):
rv = webclient.get('/')
assert b'auth-button-div' in rv.data
......@@ -21,6 +24,7 @@ def test_webclient_buttons(webclient):
# no test for plugin.bp.route, impossible to
# add route dynamically
@pytest.mark.api
def test_webclient_add_button(env, webclient):
from lektor.pluginsystem import get_plugin
plugin = get_plugin('admin-extra', env)
......@@ -35,6 +39,7 @@ def test_webclient_add_button(env, webclient):
rv = webclient.get('/admin/edit')
assert b'zorglub' in rv.data
@pytest.mark.api
def test_webclient_add_serve_button(env, webclient):
from lektor.pluginsystem import get_plugin
plugin = get_plugin('admin-extra', env)
......@@ -48,6 +53,7 @@ def test_webclient_add_serve_button(env, webclient):
print(rv.data)
assert b'albatros' not in rv.data
@pytest.mark.api
def test_webclient_add_dash_button(env, webclient):
from lektor.pluginsystem import get_plugin
plugin = get_plugin('admin-extra', env)
......@@ -62,18 +68,22 @@ def test_webclient_add_dash_button(env, webclient):
print(rv.data)
assert b'Rnd0m' in rv.data
@pytest.mark.server
def test_server_started(anonymous):
rv = anonymous.get('/', timeout=0.1)
assert rv.status_code == 200
@pytest.mark.server
def test_auth_buttons(anonymous):
rv = anonymous.get('/', timeout=0.1)
assert 'auth-button-div' in rv.text
@pytest.mark.server
def test_static_file(anonymous):
rv = anonymous.get('/admin-pages/static/buttons.css', timeout=0.1)
assert 'auth-button-div' in rv.text
@pytest.mark.server
def test_help_page(anonymous):
rv = anonymous.get('/admin-pages/help', timeout=0.1)
assert 'Aide' in rv.text
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment