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

    authority = TEST_SETTINGS["h.authority"]
    db.init(db_engine,
            should_drop=True,
            should_create=True,
            authority=authority)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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()
Exemple #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"])
Exemple #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")
Exemple #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")
Exemple #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")
Exemple #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)
Exemple #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
Exemple #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)
Exemple #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)
Exemple #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)