Beispiel #1
0
def db(local_config, request):
    timezone = request.param

    db = PostgresDb.from_config(local_config,
                                application_name='test-run',
                                validate_connection=False)

    # Drop and recreate tables so our tests have a clean db.
    with db.connect() as connection:
        _core.drop_db(connection._connection)
    remove_dynamic_indexes()

    # Disable informational messages since we're doing this on every test run.
    with _increase_logging(_core._LOG) as _:
        _core.ensure_db(db._engine)

    c = db._engine.connect()
    c.execute('alter database %s set timezone = %r' %
              (local_config.db_database, str(timezone)))
    c.close()

    # We don't need informational create/drop messages for every config change.
    _dynamic._LOG.setLevel(logging.WARN)

    yield db
    db.close()
Beispiel #2
0
def db(local_config):
    db = PostgresDb.from_config(local_config, application_name='test-run', validate_db=False)
    # Drop and recreate tables so our tests have a clean db.
    drop_db(db._connection)
    remove_dynamic_indexes()
    ensure_db(db._engine)
    return db
Beispiel #3
0
def db(local_config):
    db = PostgresDb.from_config(local_config,
                                application_name='test-run',
                                validate_db=False)
    # Drop and recreate tables so our tests have a clean db.
    drop_db(db._connection)
    remove_dynamic_indexes()
    ensure_db(db._engine)
    return db
Beispiel #4
0
def db(local_config: LocalConfig):
    db = PostgresDb.from_config(local_config, application_name='dea-test-run', validate_connection=False)

    # Drop and recreate tables so our tests have a clean db.
    with db.connect() as connection:
        _core.drop_db(connection._connection)
    remove_dynamic_indexes()

    # Disable informational messages since we're doing this on every test run.
    with _increase_logging(_core._LOG) as _:
        _core.ensure_db(db._engine)

    # We don't need informational create/drop messages for every config change.
    _dynamic._LOG.setLevel(logging.WARN)

    yield db
    db.close()