File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change 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 ()
You can’t perform that action at this time.
0 commit comments