|
1 | 1 | import pytest |
2 | 2 |
|
3 | | -from ydb.query.transaction import BaseTxContext |
| 3 | +from ydb.query.transaction import BaseQueryTxContext |
4 | 4 | from ydb.query.transaction import QueryTxStateEnum |
5 | 5 |
|
6 | 6 |
|
7 | 7 | class TestQueryTransaction: |
8 | | - def test_tx_begin(self, tx: BaseTxContext): |
| 8 | + def test_tx_begin(self, tx: BaseQueryTxContext): |
9 | 9 | assert tx.tx_id is None |
10 | 10 |
|
11 | 11 | tx.begin() |
12 | 12 | assert tx.tx_id is not None |
13 | 13 |
|
14 | | - def test_tx_allow_double_commit(self, tx: BaseTxContext): |
| 14 | + def test_tx_allow_double_commit(self, tx: BaseQueryTxContext): |
15 | 15 | tx.begin() |
16 | 16 | tx.commit() |
17 | 17 | tx.commit() |
18 | 18 |
|
19 | | - def test_tx_allow_double_rollback(self, tx: BaseTxContext): |
| 19 | + def test_tx_allow_double_rollback(self, tx: BaseQueryTxContext): |
20 | 20 | tx.begin() |
21 | 21 | tx.rollback() |
22 | 22 | tx.rollback() |
23 | 23 |
|
24 | | - def test_tx_commit_before_begin(self, tx: BaseTxContext): |
| 24 | + def test_tx_commit_before_begin(self, tx: BaseQueryTxContext): |
25 | 25 | tx.commit() |
26 | 26 | assert tx._tx_state._state == QueryTxStateEnum.COMMITTED |
27 | 27 |
|
28 | | - def test_tx_rollback_before_begin(self, tx: BaseTxContext): |
| 28 | + def test_tx_rollback_before_begin(self, tx: BaseQueryTxContext): |
29 | 29 | tx.rollback() |
30 | 30 | assert tx._tx_state._state == QueryTxStateEnum.ROLLBACKED |
31 | 31 |
|
32 | | - def test_tx_first_execute_begins_tx(self, tx: BaseTxContext): |
| 32 | + def test_tx_first_execute_begins_tx(self, tx: BaseQueryTxContext): |
33 | 33 | tx.execute("select 1;") |
34 | 34 | tx.commit() |
35 | 35 |
|
36 | | - def test_interactive_tx_commit(self, tx: BaseTxContext): |
| 36 | + def test_interactive_tx_commit(self, tx: BaseQueryTxContext): |
37 | 37 | tx.execute("select 1;", commit_tx=True) |
38 | 38 | with pytest.raises(RuntimeError): |
39 | 39 | tx.execute("select 1;") |
40 | 40 |
|
41 | | - def test_tx_execute_raises_after_commit(self, tx: BaseTxContext): |
| 41 | + def test_tx_execute_raises_after_commit(self, tx: BaseQueryTxContext): |
42 | 42 | tx.begin() |
43 | 43 | tx.commit() |
44 | 44 | with pytest.raises(RuntimeError): |
45 | 45 | tx.execute("select 1;") |
46 | 46 |
|
47 | | - def test_tx_execute_raises_after_rollback(self, tx: BaseTxContext): |
| 47 | + def test_tx_execute_raises_after_rollback(self, tx: BaseQueryTxContext): |
48 | 48 | tx.begin() |
49 | 49 | tx.rollback() |
50 | 50 | with pytest.raises(RuntimeError): |
51 | 51 | tx.execute("select 1;") |
52 | 52 |
|
53 | | - def test_context_manager_rollbacks_tx(self, tx: BaseTxContext): |
| 53 | + def test_context_manager_rollbacks_tx(self, tx: BaseQueryTxContext): |
54 | 54 | with tx: |
55 | 55 | tx.begin() |
56 | 56 |
|
57 | 57 | assert tx._tx_state._state == QueryTxStateEnum.ROLLBACKED |
58 | 58 |
|
59 | | - def test_context_manager_normal_flow(self, tx: BaseTxContext): |
| 59 | + def test_context_manager_normal_flow(self, tx: BaseQueryTxContext): |
60 | 60 | with tx: |
61 | 61 | tx.begin() |
62 | 62 | tx.execute("select 1;") |
63 | 63 | tx.commit() |
64 | 64 |
|
65 | 65 | assert tx._tx_state._state == QueryTxStateEnum.COMMITTED |
66 | 66 |
|
67 | | - def test_context_manager_does_not_hide_exceptions(self, tx: BaseTxContext): |
| 67 | + def test_context_manager_does_not_hide_exceptions(self, tx: BaseQueryTxContext): |
68 | 68 | class CustomException(Exception): |
69 | 69 | pass |
70 | 70 |
|
71 | 71 | with pytest.raises(CustomException): |
72 | 72 | with tx: |
73 | 73 | raise CustomException() |
74 | 74 |
|
75 | | - def test_execute_as_context_manager(self, tx: BaseTxContext): |
| 75 | + def test_execute_as_context_manager(self, tx: BaseQueryTxContext): |
76 | 76 | tx.begin() |
77 | 77 |
|
78 | 78 | with tx.execute("select 1;") as results: |
|
0 commit comments