Skip to content

Commit 2a260be

Browse files
committed
Added close method for Connection Pool
1 parent e941865 commit 2a260be

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

python/tests/test_connection_pool.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pytest
22

33
from psqlpy import Connection, ConnRecyclingMethod, PSQLPool, QueryResult
4+
from psqlpy.exceptions import RustPSQLDriverPyBaseError
45

56
pytestmark = pytest.mark.anyio
67

@@ -59,3 +60,19 @@ async def test_pool_conn_recycling_method(
5960
await pg_pool.startup()
6061

6162
await pg_pool.execute("SELECT 1")
63+
64+
65+
async def test_close_connection_pool() -> None:
66+
"""Test that `close` method closes connection pool."""
67+
pg_pool = PSQLPool(
68+
dsn="postgres://postgres:postgres@localhost:5432/psqlpy_test",
69+
)
70+
71+
await pg_pool.startup()
72+
73+
await pg_pool.execute("SELECT 1")
74+
75+
await pg_pool.close()
76+
77+
with pytest.raises(expected_exception=RustPSQLDriverPyBaseError):
78+
await pg_pool.execute("SELECT 1")

0 commit comments

Comments
 (0)