Exemple #1
0
def test_shell_with_ssl_and_password_prompt():
    fake_expect = ExpectModule()

    the_password = '******'

    pg = PostgresDB(user='******', password=the_password,
                    sslmode='require', sslcert='test.pem', sslkey='test.key')
    pg.shell(fake_expect)

    assert fake_expect.expect.password == the_password

    assert fake_expect.expect.cmd == 'psql ' \
        '"dbname=postgres user=foo host=localhost port=5432 ' \
        'sslmode=require sslcert=test.pem sslkey=test.key"'
Exemple #2
0
def test_shell_with_ssl_and_password_prompt():
    fake_expect = ExpectModule()

    the_password = '******'

    pg = PostgresDB(user='******',
                    password=the_password,
                    sslmode='require',
                    sslcert='test.pem',
                    sslkey='test.key')
    pg.shell(fake_expect)

    assert fake_expect.expect.password == the_password

    assert fake_expect.expect.cmd == 'psql ' \
        '"dbname=postgres user=foo host=localhost port=5432 ' \
        'sslmode=require sslcert=test.pem sslkey=test.key"'
Exemple #3
0
def test_postgres_is_not_available():
    db = PostgresDB(host='pydbadmin_fake_hostname')
    assert not db.available(timeout=0.25)
Exemple #4
0
def test_connection_url():
    user = getpass.getuser()
    assert PostgresDB().connection_url(
    ) == 'postgresql://%s@localhost:5432/postgres' % user
    assert PostgresDB().connection_url(
        'foo') == 'postgresql://%s@localhost:5432/foo' % user
Exemple #5
0
def test_connection_dsn():
    user = getpass.getuser()
    assert PostgresDB().connection_dsn(
    ) == 'dbname=postgres user=%s host=localhost port=5432' % user
    assert PostgresDB().connection_dsn(
        'foo') == 'dbname=foo user=%s host=localhost port=5432' % user
Exemple #6
0
def pg():
    return PostgresDB()
Exemple #7
0
def test_postgres_is_not_available():
    db = PostgresDB(host='pydbadmin_fake_hostname')
    assert not db.available(timeout=0.25)