Beispiel #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)
Beispiel #2
0
def init_db(db_engine):

    authority = TEST_SETTINGS["h.authority"]
    db.init(db_engine,
            should_drop=True,
            should_create=True,
            authority=authority)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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
Beispiel #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)
Beispiel #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)
Beispiel #9
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)
Beispiel #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()
Beispiel #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"])
Beispiel #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")
Beispiel #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")
Beispiel #14
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=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")
Beispiel #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)
Beispiel #16
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)
    return engine
Beispiel #17
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)
Beispiel #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)
Beispiel #19
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)