You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.1 KiB
46 lines
1.1 KiB
7 years ago
|
''' 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)
|