Esempio n. 1
0
async def test_pool_by_dsn(event_loop):
    """ test creation using DSN """
    pool = AsyncPool(DRIVER, dsn=DSN, loop=event_loop)
    pytest.assume(pool.is_connected() is False)
    await pool.connect()
    pytest.assume(pool.is_connected() is True)
    db = await pool.acquire()
    result, error = await db.test_connection('helloworld')
    pytest.assume(not error)
    pytest.assume(result == 'helloworld')
    user = {
        "Name": "Pradeep",
        "Company": "SCTL",
        "Address": "Mumbai",
        "Location": "RCP",
    }
    await db.set_hash("user", user)
    pytest.assume(await db.exists("user") == 1)
    result = await db.get_hash("user")
    # print(result, await db.exists("user"))
    pytest.assume(result["Name"] == "Pradeep")
    await db.delete("user")
    pytest.assume(await db.exists("user") == 0)
    await pool.close()
    assert pool.is_closed() is True
Esempio n. 2
0
async def test_pool_by_dsn(event_loop):
    """ test creation using DSN """
    pool = AsyncPool(DRIVER, dsn=DSN, loop=event_loop)
    pytest.assume(pool.is_connected() is False)
    await pool.connect()
    pytest.assume(pool.is_connected() is True)
    db = await pool.acquire()
    result, error = await db.test_connection('helloworld')
    pytest.assume(not error)
    pytest.assume(result == 'helloworld')
    await pool.close()
    assert pool.is_closed() is True