Skip to content

Commit 6d8d379

Browse files
committed
Started implementing chain to create pool
Signed-off-by: chandr-andr (Kiselev Aleksandr) <chandr@chandr.net>
1 parent 5f36edd commit 6d8d379

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import pytest
2+
3+
from psqlpy import (
4+
ConnectionPoolBuilder,
5+
ConnRecyclingMethod,
6+
LoadBalanceHosts,
7+
SslMode,
8+
TargetSessionAttrs,
9+
)
10+
11+
pytestmark = pytest.mark.anyio
12+
13+
14+
async def test_connection_pool_builder(
15+
postgres_host: str,
16+
postgres_user: str,
17+
postgres_password: str,
18+
postgres_port: int,
19+
postgres_dbname: str,
20+
table_name: str,
21+
) -> None:
22+
"""Test connection pool builder functionality."""
23+
builder = (
24+
ConnectionPoolBuilder()
25+
.max_pool_size(10)
26+
.host(postgres_host)
27+
.port(postgres_port)
28+
.user(postgres_user)
29+
.password(postgres_password)
30+
.dbname(postgres_dbname)
31+
.conn_recycling_method(
32+
ConnRecyclingMethod.Verified,
33+
)
34+
.options("")
35+
.application_name("testing")
36+
.ssl_mode(SslMode.Disable)
37+
.connect_timeout(10)
38+
.tcp_user_timeout(100)
39+
.target_session_attrs(
40+
TargetSessionAttrs.ReadWrite,
41+
)
42+
.load_balance_hosts(
43+
LoadBalanceHosts.Disable,
44+
)
45+
.keepalives(True)
46+
.keepalives_idle(10)
47+
.keepalives_interval(10)
48+
.keepalives_retries(10)
49+
)
50+
51+
pool = builder.build()
52+
53+
results = await pool.execute(
54+
querystring=f"SELECT * FROM {table_name}",
55+
)
56+
57+
assert results.result()

0 commit comments

Comments
 (0)