Ejemplo n.º 1
0
def db_conn():
    # Will be executed before the first test
    connection = GPConnection()
    sql_conn = connection.connect(host, port, db, user, password)
    yield sql_conn
    # Will be executed after the last test
    connection.close(1)
Ejemplo n.º 2
0
def test_database_conn_list():
    connection = GPConnection()
    conn1 = connection.connect(host, port, db, user, password)
    assert conn1 is not None
    conn2 = connection.connect(host, port, db, user, password)
    assert conn2 is not None
    conn_temp = connection.get_connection(1)
    assert conn_temp is not None
Ejemplo n.º 3
0
def test_database_conn_close():
    connection = GPConnection()
    conn = connection.connect(host, port, db, user, password)
    conn2 = connection.connect(host, port, db, user, password)
    assert len(connection.connection_pool) == 2
    connection.close(1)
    assert len(connection.connection_pool) == 1
Ejemplo n.º 4
0
def test_database_conn_fail():
    with pytest.raises(Exception) as e:
        connection = GPConnection()
        assert connection.connect(host, port, 'no_exist_db', user, password)
Ejemplo n.º 5
0
def test_database_conn_success():
    connection = GPConnection()
    conn = connection.connect(host, port, db, user, password)
    assert conn is not None