Skip to content

Commit 59b8b49

Browse files
Tweak tests.
1 parent 9f59b22 commit 59b8b49

File tree

2 files changed

+32
-28
lines changed

2 files changed

+32
-28
lines changed

tests/test_8700_sessionless_transaction.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -673,19 +673,21 @@ def test_8715(conn, cursor, test_env):
673673
cursor.execute(f"drop table {temp_table_name} purge")
674674

675675

676-
def test_8716(conn, cursor, test_env):
676+
def test_8716(test_env):
677677
"8716 - test suspend_on_success with batch_size < total rows inserted"
678-
cursor.execute("truncate table TestTempTable")
679-
rows = [(i + 1, f"String for row {i + 1}") for i in range(200)]
680-
conn.begin_sessionless_transaction(
681-
transaction_id=TRANSACTION_ID_CLIENT,
682-
timeout=15,
683-
defer_round_trip=True,
684-
)
685-
with test_env.assert_raises_full_code("DPY-3036"):
686-
cursor.executemany(
687-
"insert into TestTempTable (IntCol, StringCol1) values (:1, :2)",
688-
rows,
689-
batch_size=75,
690-
suspend_on_success=True,
678+
with test_env.get_connection() as conn:
679+
cursor = conn.cursor()
680+
cursor.execute("truncate table TestTempTable")
681+
rows = [(i + 1, f"String for row {i + 1}") for i in range(200)]
682+
conn.begin_sessionless_transaction(
683+
transaction_id=TRANSACTION_ID_CLIENT,
684+
timeout=5,
685+
defer_round_trip=True,
691686
)
687+
sql = "insert into TestTempTable (IntCol, StringCol1) values (:1, :2)"
688+
with test_env.assert_raises_full_code("DPY-3036"):
689+
cursor.executemany(
690+
sql, rows, batch_size=75, suspend_on_success=True
691+
)
692+
with test_env.get_connection() as conn:
693+
conn.resume_sessionless_transaction(TRANSACTION_ID_CLIENT)

tests/test_8800_sessionless_transaction_async.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -681,19 +681,21 @@ async def test_8815(async_conn, async_cursor, test_env):
681681
await async_cursor.execute(f"drop table {temp_table_name} purge")
682682

683683

684-
async def test_8816(async_conn, async_cursor, test_env):
684+
async def test_8816(test_env):
685685
"8816 - test suspend_on_success with batch_size < total rows inserted"
686-
await async_cursor.execute("truncate table TestTempTable")
687-
rows = [(i + 1, f"String for row {i + 1}") for i in range(200)]
688-
await async_conn.begin_sessionless_transaction(
689-
transaction_id=TRANSACTION_ID_CLIENT,
690-
timeout=15,
691-
defer_round_trip=True,
692-
)
693-
with test_env.assert_raises_full_code("DPY-3036"):
694-
await async_cursor.executemany(
695-
"insert into TestTempTable (IntCol, StringCol1) values (:1, :2)",
696-
rows,
697-
batch_size=75,
698-
suspend_on_success=True,
686+
async with test_env.get_connection_async() as conn:
687+
cursor = conn.cursor()
688+
await cursor.execute("truncate table TestTempTable")
689+
rows = [(i + 1, f"String for row {i + 1}") for i in range(200)]
690+
await conn.begin_sessionless_transaction(
691+
transaction_id=TRANSACTION_ID_CLIENT,
692+
timeout=5,
693+
defer_round_trip=True,
699694
)
695+
sql = "insert into TestTempTable (IntCol, StringCol1) values (:1, :2)"
696+
with test_env.assert_raises_full_code("DPY-3036"):
697+
await cursor.executemany(
698+
sql, rows, batch_size=75, suspend_on_success=True
699+
)
700+
async with test_env.get_connection_async() as conn:
701+
await conn.resume_sessionless_transaction(TRANSACTION_ID_CLIENT)

0 commit comments

Comments
 (0)