Beispiel #1
0
def get_pool(**kwargs):  # pragma: no cover
    '''
    Gets the postgresql connection pool.

    :return: pool
    '''
    db_url = kwargs.pop('db_url')
    kwargs.update(parse_pgurl(db_url))

    pool = yield from aiopg.create_pool(**kwargs)

    return pool
Beispiel #2
0
def pytest_configure():
    db_url = "postgres://postgres@localhost:5432/chilero_pg_{}".format(TEST_DB_SUFFIX)
    # Drop old test database, if exists
    drop_database(db_url)

    # Create a new, empty, test database
    create_database(db_url)

    # Fill the test database with initial structure
    dbdata = parse_pgurl(db_url)
    conn = psycopg2.connect(**dbdata)
    conn.set_isolation_level(0)
    cur = conn.cursor()
    with open("tests/data/db.sql") as f:
        cur.execute(f.read())
    cur.close()
    conn.close()
Beispiel #3
0
def pytest_configure():
    db_url = 'postgres://postgres@localhost:5432/chilero_pg_{}'.format(
        TEST_DB_SUFFIX)
    # Drop old test database, if exists
    drop_database(db_url)

    # Create a new, empty, test database
    create_database(db_url)

    # Fill the test database with initial structure
    dbdata = parse_pgurl(db_url)
    conn = psycopg2.connect(**dbdata)
    conn.set_isolation_level(0)
    cur = conn.cursor()
    with open('tests/data/db.sql') as f:
        cur.execute(f.read())
    cur.close()
    conn.close()