Skip to content

Commit 96636d1

Browse files
Added test case for tpc_rollback() with xid parameter.
1 parent ad8709f commit 96636d1

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/test_4400_tpc.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,29 @@ def test_4402_tpc_multiple_transactions(self):
9292
expected_rows = [(1, 'tesName'), (2, 'tesName')]
9393
self.assertEqual(self.cursor.fetchall(), expected_rows)
9494

95+
def test_4403_rollback_with_xid(self):
96+
"4403 - test rollback with parameter xid"
97+
self.cursor.execute("truncate table TestTempTable")
98+
xid1 = self.connection.xid(3901, "txn3901", "branch1")
99+
xid2 = self.connection.xid(3902, "txn3902", "branch2")
100+
for count, xid in enumerate([xid1, xid2]):
101+
self.connection.tpc_begin(xid)
102+
self.cursor.execute("""
103+
insert into TestTempTable (IntCol, StringCol1)
104+
values (:id, 'tesName')""", id=count)
105+
self.connection.tpc_end()
106+
self.connection.tpc_rollback(xid1)
107+
108+
self.assertRaisesRegex(oracledb.DatabaseError, "^ORA-24756",
109+
self.connection.tpc_prepare, xid1)
110+
needs_commit = self.connection.tpc_prepare(xid2)
111+
if needs_commit:
112+
self.connection.tpc_commit(xid2)
113+
self.cursor.execute("""
114+
select IntCol, StringCol1
115+
from TestTempTable
116+
order by IntCol""")
117+
self.assertEqual(self.cursor.fetchall(), [(1, 'tesName')])
118+
95119
if __name__ == "__main__":
96120
test_env.run_test_cases()

0 commit comments

Comments
 (0)