コード例 #1
0
def sqlengine(request):
    engine = create_engine(TEST_DATABASE_URL)
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)

    def teardown():
        Base.metadata.drop_all(engine)

    request.addfinalizer(teardown)
    return engine
コード例 #2
0
def sqlengine(request):
    engine = create_engine(TEST_DATABASE_URL)
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)

    def teardown():
        Base.metadata.drop_all(engine)

    request.addfinalizer(teardown)
    return engine
コード例 #3
0
def dbtransaction(request, sqlengine):
    connection = sqlengine.connect()
    transaction = connection.begin()
    DBSession.configure(bind=connection)

    def teardown():
        transaction.rollback()
        connection.close()
        DBSession.remove()

    request.addfinalizer(teardown)
    return connection
コード例 #4
0
ファイル: conftest.py プロジェクト: Mikekh84/learning-journal
def dbtransaction(request, sqlengine):
    connection = sqlengine.connect()
    transaction = connection.begin()
    DBSession.configure(bind=connection)

    def teardown():
        transaction.rollback()
        connection.close()
        DBSession.remove()

    request.addfinalizer(teardown)
    return connection
コード例 #5
0
def new_model(request, sqlengine, dbtransaction):
    """Create an entry to testing db."""
    connection = sqlengine.connect()
    transaction = connection.begin()
    DBSession.configure(bind=connection)
    new_model = Entry(title="jill", text='jello')
    DBSession.add(new_model)
    DBSession.flush()

    def teardown():
        transaction.rollback()
        connection.close()
        DBSession.remove()

    request.addfinalizer(teardown)
    return new_model
コード例 #6
0
ファイル: conftest.py プロジェクト: Mikekh84/learning-journal
def new_model(request, sqlengine, dbtransaction):
    """Create an entry to testing db."""
    connection = sqlengine.connect()
    transaction = connection.begin()
    DBSession.configure(bind=connection)
    new_model = Entry(title="jill", text='jello')
    DBSession.add(new_model)
    DBSession.flush()

    def teardown():
        transaction.rollback()
        connection.close()
        DBSession.remove()

    request.addfinalizer(teardown)
    return new_model
コード例 #7
0
ファイル: __init__.py プロジェクト: 43-stuti/gevent-socketio
def main(global_config, **settings):
    config = Configurator()

    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)

    simple_route(config, 'index', '/', index)

    # The socketio view configuration
    config.add_route('socket_io', 'socket.io/*remaining')

    config.add_static_view('static', 'static', cache_max_age=3600)

    config.scan('testapp.views')

    app = config.make_wsgi_app()

    return app
コード例 #8
0
def main(global_config, **settings):
    config = Configurator()

    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)

    simple_route(config, 'index', '/', index)

    # The socketio view configuration
    config.add_route('socket_io', 'socket.io/*remaining')

    config.add_static_view('static', 'static', cache_max_age=3600)

    config.scan('testapp.views')

    app = config.make_wsgi_app()

    return app