33from __future__ import annotations
44
55import json
6+ import uuid
67
78import pytest
89
910from runloop_api_client .sdk import AsyncRunloopSDK
1011
12+
13+ def _unique_table () -> str :
14+ return f"t_{ uuid .uuid4 ().hex [:12 ]} "
15+
16+
1117pytestmark = [pytest .mark .smoketest , pytest .mark .asyncio ]
1218
1319THIRTY_SECOND_TIMEOUT = 30
@@ -76,12 +82,13 @@ class TestAsyncAxonSql:
7682 async def test_sql_query_create_and_select (self , async_sdk_client : AsyncRunloopSDK ) -> None :
7783 """Test creating a table and querying it via sql.query."""
7884 axon = await async_sdk_client .axon .create ()
85+ table = _unique_table ()
7986
80- await axon .sql .query (sql = "CREATE TABLE IF NOT EXISTS smoke_test (id INTEGER PRIMARY KEY, value TEXT)" )
87+ await axon .sql .query (sql = f "CREATE TABLE { table } (id INTEGER PRIMARY KEY, value TEXT)" )
8188
82- await axon .sql .query (sql = "INSERT INTO smoke_test (id, value) VALUES (?, ?)" , params = [1 , "hello" ])
89+ await axon .sql .query (sql = f "INSERT INTO { table } (id, value) VALUES (?, ?)" , params = [1 , "hello" ])
8390
84- result = await axon .sql .query (sql = "SELECT * FROM smoke_test WHERE id = ?" , params = [1 ])
91+ result = await axon .sql .query (sql = f "SELECT * FROM { table } WHERE id = ?" , params = [1 ])
8592
8693 assert result .columns is not None
8794 assert len (result .columns ) > 0
@@ -92,13 +99,14 @@ async def test_sql_query_create_and_select(self, async_sdk_client: AsyncRunloopS
9299 async def test_sql_batch (self , async_sdk_client : AsyncRunloopSDK ) -> None :
93100 """Test executing multiple statements atomically via sql.batch."""
94101 axon = await async_sdk_client .axon .create ()
102+ table = _unique_table ()
95103
96104 result = await axon .sql .batch (
97105 statements = [
98- {"sql" : "CREATE TABLE IF NOT EXISTS batch_test (id INTEGER PRIMARY KEY, name TEXT)" },
99- {"sql" : "INSERT INTO batch_test (id, name) VALUES (?, ?)" , "params" : [1 , "alice" ]},
100- {"sql" : "INSERT INTO batch_test (id, name) VALUES (?, ?)" , "params" : [2 , "bob" ]},
101- {"sql" : "SELECT * FROM batch_test ORDER BY id" },
106+ {"sql" : f "CREATE TABLE { table } (id INTEGER PRIMARY KEY, name TEXT)" },
107+ {"sql" : f "INSERT INTO { table } (id, name) VALUES (?, ?)" , "params" : [1 , "alice" ]},
108+ {"sql" : f "INSERT INTO { table } (id, name) VALUES (?, ?)" , "params" : [2 , "bob" ]},
109+ {"sql" : f "SELECT * FROM { table } ORDER BY id" },
102110 ],
103111 )
104112
0 commit comments