-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathtest_connection_pool_builder.py
More file actions
56 lines (51 loc) · 1.35 KB
/
test_connection_pool_builder.py
File metadata and controls
56 lines (51 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import pytest
from psqlpy import (
ConnectionPoolBuilder,
ConnRecyclingMethod,
LoadBalanceHosts,
SslMode,
TargetSessionAttrs,
)
pytestmark = pytest.mark.anyio
async def test_connection_pool_builder(
postgres_host: str,
postgres_user: str,
postgres_password: str,
postgres_port: int,
postgres_dbname: str,
table_name: str,
) -> None:
"""Test connection pool builder functionality."""
builder = (
ConnectionPoolBuilder()
.max_pool_size(10)
.host(postgres_host)
.port(postgres_port)
.user(postgres_user)
.password(postgres_password)
.dbname(postgres_dbname)
.conn_recycling_method(
ConnRecyclingMethod.Verified,
)
.options("")
.application_name("testing")
.ssl_mode(SslMode.Disable)
.connect_timeout(10)
.tcp_user_timeout(100)
.target_session_attrs(
TargetSessionAttrs.ReadWrite,
)
.load_balance_hosts(
LoadBalanceHosts.Disable,
)
.keepalives(True)
.keepalives_idle(10)
.keepalives_interval(10)
.keepalives_retries(10)
)
pool = builder.build()
connection = await pool.connection()
results = await connection.execute(
querystring=f"SELECT * FROM {table_name}",
)
assert results.result()