Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 4
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
Ejemplo n.º 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
Ejemplo n.º 6
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
Ejemplo n.º 7
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
Ejemplo n.º 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