Ejemplo n.º 1
0
def init_db(db_engine):
    from h import db
    authority = TEST_SETTINGS['h.authority']
    db.init(db_engine,
            should_drop=True,
            should_create=True,
            authority=authority)
Ejemplo n.º 2
0
def init_db(db_engine):

    authority = TEST_SETTINGS["h.authority"]
    db.init(db_engine,
            should_drop=True,
            should_create=True,
            authority=authority)
Ejemplo n.º 3
0
def app(pyramid_app, db_engine):
    from h import db

    _clean_database(db_engine)
    db.init(db_engine, authority=text_type(TEST_SETTINGS['h.authority']))

    return TestApp(pyramid_app)
Ejemplo n.º 4
0
def app(pyramid_app, db_engine):
    from h import db

    _clean_database(db_engine)
    db.init(db_engine, authority=TEST_SETTINGS["h.authority"])

    return TestApp(pyramid_app)
Ejemplo n.º 5
0
def app(pyramid_app, db_engine):
    from h import db

    _clean_database(db_engine)
    db.init(db_engine, authority=text_type(TEST_SETTINGS['h.authority']))

    return TestApp(pyramid_app)
Ejemplo n.º 6
0
def db_engine():
    """Set up the database connection and create tables."""
    engine = sqlalchemy.create_engine(TEST_DATABASE_URL)
    db.init(engine,
            should_create=True,
            should_drop=True,
            authority=TEST_AUTHORITY)
    return engine
Ejemplo n.º 7
0
def init_db(db_engine):
    from h import db

    authority = text_type(TEST_SETTINGS["h.authority"])
    db.init(db_engine,
            should_drop=True,
            should_create=True,
            authority=authority)
Ejemplo n.º 8
0
def app(pyramid_app, db_engine):
    from h import db

    _clean_database(db_engine)
    _clean_elasticsearch(TEST_SETTINGS)
    db.init(db_engine, authority=TEST_SETTINGS['h.authority'])

    return TestApp(pyramid_app)
Ejemplo n.º 9
0
Archivo: conftest.py Proyecto: gnott/h
def app(pyramid_app, db_engine):
    from h import db

    _clean_database(db_engine)
    _clean_elasticsearch(TEST_SETTINGS)
    db.init(db_engine, authority=TEST_SETTINGS['h.authority'])

    return TestApp(pyramid_app)
Ejemplo n.º 10
0
def db_engine():
    db_engine = db.make_engine(TEST_SETTINGS)
    db.init(db_engine,
            authority=TEST_SETTINGS["h.authority"],
            should_create=True)

    yield db_engine

    db_engine.dispose()
Ejemplo n.º 11
0
def with_clean_db(db_engine):
    tables = reversed(db.Base.metadata.sorted_tables)
    with contextlib.closing(db_engine.connect()) as conn:
        tx = conn.begin()
        tnames = ", ".join('"' + t.name + '"' for t in tables)
        conn.execute(f"TRUNCATE {tnames};")
        tx.commit()

    # We need to re-init the DB as it creates the default test group and
    # possibly more in future?
    db.init(db_engine, authority=TEST_SETTINGS["h.authority"])
Ejemplo n.º 12
0
def _init_db(settings):
    engine = db.make_engine(settings)

    # If the alembic_version table is present, then the database is managed by
    # alembic, and we shouldn't call `db.init`.
    try:
        engine.execute('select 1 from alembic_version')
    except sqlalchemy.exc.ProgrammingError:
        log.info("initializing database")
        db.init(engine, should_create=True, authority=settings['h.authority'])
    else:
        log.info("detected alembic_version table, skipping db initialization")
Ejemplo n.º 13
0
def _init_db(settings):
    engine = db.make_engine(settings)

    # If the alembic_version table is present, then the database is managed by
    # alembic, and we shouldn't call `db.init`.
    try:
        engine.execute("select 1 from alembic_version")
    except sqlalchemy.exc.ProgrammingError:
        log.info("initializing database")
        db.init(engine, should_create=True, authority=settings["h.authority"])

        # Stamp the database with the current schema version so that future
        # migrations start from the correct point.
        alembic_cfg = alembic.config.Config("conf/alembic.ini")
        alembic.command.stamp(alembic_cfg, "head")
    else:
        log.info("detected alembic_version table, skipping db initialization")
Ejemplo n.º 14
0
Archivo: init.py Proyecto: hypothesis/h
def _init_db(settings):
    engine = db.make_engine(settings)

    # If the alembic_version table is present, then the database is managed by
    # alembic, and we shouldn't call `db.init`.
    try:
        engine.execute("select 1 from alembic_version")
    except sqlalchemy.exc.ProgrammingError:
        log.info("initializing database")
        db.init(
            engine, should_create=True, authority=text_type(settings["h.authority"])
        )

        # Stamp the database with the current schema version so that future
        # migrations start from the correct point.
        alembic_cfg = alembic.config.Config("conf/alembic.ini")
        alembic.command.stamp(alembic_cfg, "head")
    else:
        log.info("detected alembic_version table, skipping db initialization")
Ejemplo n.º 15
0
def init_db(db_engine):
    from h import db

    authority = text_type(TEST_SETTINGS["h.authority"])
    db.init(db_engine, should_drop=True, should_create=True, authority=authority)
Ejemplo n.º 16
0
Archivo: conftest.py Proyecto: nlisgo/h
def db_engine():
    """Set up the database connection and create tables."""
    engine = sqlalchemy.create_engine(TEST_DATABASE_URL)
    db.init(engine, should_create=True, should_drop=True)
    return engine
Ejemplo n.º 17
0
Archivo: conftest.py Proyecto: nlisgo/h
def init_db(db_engine):
    from h import db
    from h import models  # noqa
    db.init(db_engine, should_drop=True, should_create=True)
Ejemplo n.º 18
0
def init_db(db_engine):
    from h import db
    from h import models  # noqa
    db.init(db_engine, should_drop=True, should_create=True)
Ejemplo n.º 19
0
Archivo: conftest.py Proyecto: gnott/h
def init_db(db_engine):
    from h import db
    authority = TEST_SETTINGS['h.authority']
    db.init(db_engine, should_drop=True, should_create=True, authority=authority)