Skip to content

Commit 8973ef6

Browse files
committed
cp dines
1 parent bb3e2cb commit 8973ef6

4 files changed

Lines changed: 31 additions & 13 deletions

File tree

src/runloop_api_client/sdk/async_axon.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ class AsyncAxon:
6464
def __init__(self, client: AsyncRunloop, axon_id: str) -> None:
6565
self._client = client
6666
self._id = axon_id
67-
self.sql = AsyncAxonSqlOps(client, axon_id)
67+
self._sql = AsyncAxonSqlOps(client, axon_id)
68+
69+
@property
70+
def sql(self) -> AsyncAxonSqlOps:
71+
return self._sql
6872

6973
@override
7074
def __repr__(self) -> str:

src/runloop_api_client/sdk/axon.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ class Axon:
6464
def __init__(self, client: Runloop, axon_id: str) -> None:
6565
self._client = client
6666
self._id = axon_id
67-
self.sql = AxonSqlOps(client, axon_id)
67+
self._sql = AxonSqlOps(client, axon_id)
68+
69+
@property
70+
def sql(self) -> AxonSqlOps:
71+
return self._sql
6872

6973
@override
7074
def __repr__(self) -> str:

tests/smoketests/sdk/test_async_axon.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@
33
from __future__ import annotations
44

55
import json
6+
import uuid
67

78
import pytest
89

910
from runloop_api_client.sdk import AsyncRunloopSDK
1011

12+
13+
def _unique_table() -> str:
14+
return f"t_{uuid.uuid4().hex[:12]}"
15+
16+
1117
pytestmark = [pytest.mark.smoketest, pytest.mark.asyncio]
1218

1319
THIRTY_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

tests/smoketests/sdk/test_axon.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
def _unique_table() -> str:
1414
return f"t_{uuid.uuid4().hex[:12]}"
1515

16+
1617
pytestmark = [pytest.mark.smoketest]
1718

1819
THIRTY_SECOND_TIMEOUT = 30
@@ -98,13 +99,14 @@ def test_sql_query_create_and_select(self, sdk_client: RunloopSDK) -> None:
9899
def test_sql_batch(self, sdk_client: RunloopSDK) -> None:
99100
"""Test executing multiple statements atomically via sql.batch."""
100101
axon = sdk_client.axon.create()
102+
table = _unique_table()
101103

102104
result = axon.sql.batch(
103105
statements=[
104-
{"sql": "CREATE TABLE IF NOT EXISTS batch_test (id INTEGER PRIMARY KEY, name TEXT)"},
105-
{"sql": "INSERT INTO batch_test (id, name) VALUES (?, ?)", "params": [1, "alice"]},
106-
{"sql": "INSERT INTO batch_test (id, name) VALUES (?, ?)", "params": [2, "bob"]},
107-
{"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"},
108110
],
109111
)
110112

0 commit comments

Comments
 (0)