@@ -56,25 +56,13 @@ def create_sqlalchemy_engine(
5656 return engine , connector
5757
5858
59- # Fallback to playground values if env vars are missing
60- def get_env (key : str , default : str = "" ) -> str :
61- # Map standard env vars to our playground values as defaults
62- defaults = {
63- "POSTGRES_CONNECTION_NAME" : "galakp-playground:us-east7:pg-us-east7-psycopg" ,
64- "POSTGRES_USER" : "postgres" ,
65- "POSTGRES_PASS" : "SuperPass123!" ,
66- "POSTGRES_DB" : "postgres" ,
67- }
68- return os .getenv (key , defaults .get (key , default ))
69-
70-
7159def test_psycopg_connection () -> None :
7260 """Basic test to get time from database using psycopg."""
73- inst_conn_name = get_env ( "POSTGRES_CONNECTION_NAME" )
74- user = get_env ( "POSTGRES_USER" )
75- password = get_env ( "POSTGRES_PASS" )
76- db = get_env ( "POSTGRES_DB" )
77- ip_type = os .getenv ("IP_TYPE" , "public" )
61+ inst_conn_name = os . environ [ "POSTGRES_CONNECTION_NAME" ]
62+ user = os . environ [ "POSTGRES_USER" ]
63+ password = os . environ [ "POSTGRES_PASS" ]
64+ db = os . environ [ "POSTGRES_DB" ]
65+ ip_type = os .environ . get ("IP_TYPE" , "public" )
7866
7967 engine , connector = create_sqlalchemy_engine (
8068 inst_conn_name , user , password , db , ip_type
@@ -89,11 +77,11 @@ def test_psycopg_connection() -> None:
8977
9078def test_lazy_psycopg_connection () -> None :
9179 """Basic test to get time from database using psycopg and lazy refresh."""
92- inst_conn_name = get_env ( "POSTGRES_CONNECTION_NAME" )
93- user = get_env ( "POSTGRES_USER" )
94- password = get_env ( "POSTGRES_PASS" )
95- db = get_env ( "POSTGRES_DB" )
96- ip_type = os .getenv ("IP_TYPE" , "public" )
80+ inst_conn_name = os . environ [ "POSTGRES_CONNECTION_NAME" ]
81+ user = os . environ [ "POSTGRES_USER" ]
82+ password = os . environ [ "POSTGRES_PASS" ]
83+ db = os . environ [ "POSTGRES_DB" ]
84+ ip_type = os .environ . get ("IP_TYPE" , "public" )
9785
9886 engine , connector = create_sqlalchemy_engine (
9987 inst_conn_name , user , password , db , ip_type , "lazy"
@@ -109,10 +97,10 @@ def test_lazy_psycopg_connection() -> None:
10997def test_CAS_psycopg_connection () -> None :
11098 """Basic test to get time from database using CAS."""
11199 inst_conn_name = os .environ .get ("POSTGRES_CAS_CONNECTION_NAME" )
112- user = get_env ( "POSTGRES_USER" )
100+ user = os . environ [ "POSTGRES_USER" ]
113101 password = os .environ .get ("POSTGRES_CAS_PASS" )
114- db = get_env ( "POSTGRES_DB" )
115- ip_type = os .getenv ("IP_TYPE" , "public" )
102+ db = os . environ [ "POSTGRES_DB" ]
103+ ip_type = os .environ . get ("IP_TYPE" , "public" )
116104
117105 if not inst_conn_name or not password :
118106 pytest .skip ("POSTGRES_CAS_CONNECTION_NAME or POSTGRES_CAS_PASS not set" )
@@ -131,10 +119,10 @@ def test_CAS_psycopg_connection() -> None:
131119def test_customer_managed_CAS_psycopg_connection () -> None :
132120 """Basic test to get time from database using Customer Managed CAS."""
133121 inst_conn_name = os .environ .get ("POSTGRES_CUSTOMER_CAS_CONNECTION_NAME" )
134- user = get_env ( "POSTGRES_USER" )
122+ user = os . environ [ "POSTGRES_USER" ]
135123 password = os .environ .get ("POSTGRES_CUSTOMER_CAS_PASS" )
136- db = get_env ( "POSTGRES_DB" )
137- ip_type = os .getenv ("IP_TYPE" , "public" )
124+ db = os . environ [ "POSTGRES_DB" ]
125+ ip_type = os .environ . get ("IP_TYPE" , "public" )
138126
139127 if not inst_conn_name or not password :
140128 pytest .skip ("POSTGRES_CUSTOMER_CAS_CONNECTION_NAME or POSTGRES_CUSTOMER_CAS_PASS not set" )
@@ -153,10 +141,10 @@ def test_customer_managed_CAS_psycopg_connection() -> None:
153141def test_custom_SAN_with_dns_psycopg_connection () -> None :
154142 """Basic test to get time from database using Custom SAN with DNS."""
155143 inst_conn_name = os .environ .get ("POSTGRES_CUSTOMER_CAS_PASS_VALID_DOMAIN_NAME" )
156- user = get_env ( "POSTGRES_USER" )
144+ user = os . environ [ "POSTGRES_USER" ]
157145 password = os .environ .get ("POSTGRES_CUSTOMER_CAS_PASS" )
158- db = get_env ( "POSTGRES_DB" )
159- ip_type = os .getenv ("IP_TYPE" , "public" )
146+ db = os . environ [ "POSTGRES_DB" ]
147+ ip_type = os .environ . get ("IP_TYPE" , "public" )
160148
161149 if not inst_conn_name or not password :
162150 pytest .skip ("POSTGRES_CUSTOMER_CAS_PASS_VALID_DOMAIN_NAME or POSTGRES_CUSTOMER_CAS_PASS not set" )
@@ -175,10 +163,10 @@ def test_custom_SAN_with_dns_psycopg_connection() -> None:
175163def test_MCP_psycopg_connection () -> None :
176164 """Basic test to get time from database using MCP enabled instance."""
177165 inst_conn_name = os .environ .get ("POSTGRES_MCP_CONNECTION_NAME" )
178- user = get_env ( "POSTGRES_USER" )
166+ user = os . environ [ "POSTGRES_USER" ]
179167 password = os .environ .get ("POSTGRES_MCP_PASS" )
180- db = get_env ( "POSTGRES_DB" )
181- ip_type = os .getenv ("IP_TYPE" , "public" )
168+ db = os . environ [ "POSTGRES_DB" ]
169+ ip_type = os .environ . get ("IP_TYPE" , "public" )
182170
183171 if not inst_conn_name or not password :
184172 pytest .skip ("POSTGRES_MCP_CONNECTION_NAME or POSTGRES_MCP_PASS not set" )
@@ -196,10 +184,10 @@ def test_MCP_psycopg_connection() -> None:
196184
197185def test_system_psycopg_to_thread () -> None :
198186 """Verify that running sync connect in asyncio.to_thread works."""
199- inst_conn_name = get_env ( "POSTGRES_CONNECTION_NAME" )
200- user = get_env ( "POSTGRES_USER" )
201- password = get_env ( "POSTGRES_PASS" )
202- db = get_env ( "POSTGRES_DB" )
187+ inst_conn_name = os . environ [ "POSTGRES_CONNECTION_NAME" ]
188+ user = os . environ [ "POSTGRES_USER" ]
189+ password = os . environ [ "POSTGRES_PASS" ]
190+ db = os . environ [ "POSTGRES_DB" ]
203191
204192 async def run_connect ():
205193 with Connector () as connector :
0 commit comments