Skip to content

Commit e1c94c7

Browse files
test: add asyncpg MCP test
1 parent d5fa0e8 commit e1c94c7

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/system/test_asyncpg_connection.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,25 @@ async def test_custom_SAN_with_dns_sqlalchemy_connection_with_asyncpg() -> None:
220220
await connector.close_async()
221221

222222

223+
async def test_MCP_sqlalchemy_connection_with_asyncpg() -> None:
224+
"""Basic test to get time from database using MCP enabled instance."""
225+
inst_conn_name = os.environ["POSTGRES_MCP_CONNECTION_NAME"]
226+
user = os.environ["POSTGRES_USER"]
227+
password = os.environ["POSTGRES_MCP_PASS"]
228+
db = os.environ["POSTGRES_DB"]
229+
ip_type = os.environ.get("IP_TYPE", "public")
230+
231+
pool, connector = await create_sqlalchemy_engine(
232+
inst_conn_name, user, password, db, ip_type
233+
)
234+
235+
async with pool.connect() as conn:
236+
res = (await conn.execute(sqlalchemy.text("SELECT 1"))).fetchone()
237+
assert res[0] == 1
238+
239+
await connector.close_async()
240+
241+
223242
async def test_connection_with_asyncpg() -> None:
224243
"""Basic test to get time from database."""
225244
inst_conn_name = os.environ["POSTGRES_CONNECTION_NAME"]

0 commit comments

Comments
 (0)