From 5fbc2dd4f0fda57275d8a3a6dc1842b1310811b3 Mon Sep 17 00:00:00 2001 From: Holger Frey Date: Mon, 16 Oct 2017 16:55:50 +0200 Subject: [PATCH] added functional tests for (static) pages --- tests/_functional/__init__.py | 45 +++++++++++++++++++++++++++ tests/_functional/layout_and_pages.py | 33 ++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 tests/_functional/__init__.py create mode 100644 tests/_functional/layout_and_pages.py diff --git a/tests/_functional/__init__.py b/tests/_functional/__init__.py new file mode 100644 index 0000000..a5b9894 --- /dev/null +++ b/tests/_functional/__init__.py @@ -0,0 +1,45 @@ +''' functional tests for ordr2 ''' + +import os.path +import pytest +import transaction +import webtest + +from .. import APP_SETTINGS, create_users + + +# some path mangling to get the path to passlib.ini +currrent_dir = os.path.dirname(__file__) +ordr2_dir = os.path.dirname(os.path.dirname(currrent_dir)) +passlib_config_path = os.path.join(ordr2_dir, 'passlib.ini') + + +WEBTEST_SETTINGS = APP_SETTINGS.copy() +WEBTEST_SETTINGS.update({ + 'pyramid.includes': ['pyramid_jinja2'], + 'passlib.config': passlib_config_path + }) + + +@pytest.fixture(scope='module') +def testapp(): + ''' fixture for using webtest ''' + from ordr2.models.meta import Base + from ordr2.models import get_tm_session, Role + from ordr2 import main + + app = main({}, **WEBTEST_SETTINGS) + testapp = webtest.TestApp(app) + + session_factory = app.registry['dbsession_factory'] + engine = session_factory.kw['bind'] + Base.metadata.create_all(engine) + + with transaction.manager: + # set up test data here + dbsession = get_tm_session(session_factory, transaction.manager) + create_users(dbsession) + + yield testapp + + Base.metadata.drop_all(engine) diff --git a/tests/_functional/layout_and_pages.py b/tests/_functional/layout_and_pages.py new file mode 100644 index 0000000..7b8bf73 --- /dev/null +++ b/tests/_functional/layout_and_pages.py @@ -0,0 +1,33 @@ +''' tests for the common layout and simple (static)''' + +from . import testapp + + +def test_page_welcome_unauthenticated(testapp): + ''' test the welcome page for a unauthenticated user ''' + testapp.reset() + + response = testapp.get('/') + + # basic content test + assert 'Ordr | Welcome' in response + assert '' in response + # test that no sections are highlightet + assert '