''' 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({ }) @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)