Holger Frey
7 years ago
2 changed files with 78 additions and 0 deletions
@ -0,0 +1,45 @@
@@ -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) |
@ -0,0 +1,33 @@
@@ -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 '<!-- No logged in user -->' in response |
||||
# test that no sections are highlightet |
||||
assert '<li class="nav-item active">' not in response |
||||
|
||||
|
||||
def test_faq_unauthenticated(testapp): |
||||
''' test the faq page for a unauthenticated user ''' |
||||
testapp.reset() |
||||
|
||||
response = testapp.get('/faq') |
||||
|
||||
# basic content test |
||||
assert 'Ordr | FAQ' in response |
||||
assert '<!-- No logged in user -->' in response |
||||
# test that the first section links and highlighting |
||||
li_one, li_two = response.html.find_all('li', class_='nav-item') |
||||
assert 'active' in li_one['class'] |
||||
assert li_one.find('a').text == 'FAQs' |
||||
assert 'active' not in li_two['class'] |
||||
assert li_two.find('a').text == 'Register' |
Reference in new issue