|
19 | 19 | # limitations under the License.
|
20 | 20 |
|
21 | 21 |
|
22 |
| -from neo4j.v1 import GraphDatabase, CypherError |
| 22 | +from neo4j.v1 import GraphDatabase, CypherError, TransientError |
23 | 23 |
|
24 | 24 | from test.stub.tools import StubTestCase, StubCluster
|
25 | 25 |
|
@@ -159,3 +159,25 @@ def unit_of_work_2(tx):
|
159 | 159 | assert value == 1
|
160 | 160 | value = session.read_transaction(unit_of_work_2)
|
161 | 161 | assert value == 2
|
| 162 | + |
| 163 | + def test_no_retry_read_on_user_canceled_tx(self): |
| 164 | + with StubCluster({9001: "router.script", 9004: "user_canceled_tx.script.script"}): |
| 165 | + uri = "bolt+routing://127.0.0.1:9001" |
| 166 | + with GraphDatabase.driver(uri, auth=self.auth_token, encrypted=False) as driver: |
| 167 | + with driver.session() as session: |
| 168 | + def unit_of_work(tx): |
| 169 | + tx.run("RETURN 1") |
| 170 | + |
| 171 | + with self.assertRaises(TransientError): |
| 172 | + _ = session.read_transaction(unit_of_work) |
| 173 | + |
| 174 | + def test_no_retry_write_on_user_canceled_tx(self): |
| 175 | + with StubCluster({9001: "router.script", 9006: "user_canceled_tx.script.script"}): |
| 176 | + uri = "bolt+routing://127.0.0.1:9001" |
| 177 | + with GraphDatabase.driver(uri, auth=self.auth_token, encrypted=False) as driver: |
| 178 | + with driver.session() as session: |
| 179 | + def unit_of_work(tx): |
| 180 | + tx.run("RETURN 1") |
| 181 | + |
| 182 | + with self.assertRaises(TransientError): |
| 183 | + _ = session.write_transaction(unit_of_work) |
0 commit comments