|
20 | 20 |
|
21 | 21 | from mock import patch
|
22 | 22 | from unittest import skipUnless
|
| 23 | +from uuid import uuid4 |
23 | 24 |
|
| 25 | +from neo4j.v1 import READ_ACCESS, WRITE_ACCESS |
24 | 26 | from neo4j.v1.exceptions import CypherError, ResultError
|
25 | 27 | from neo4j.v1.session import GraphDatabase, basic_auth, Record
|
26 | 28 | from neo4j.v1.types import Node, Relationship, Path
|
@@ -449,13 +451,33 @@ def tearDown(self):
|
449 | 451 |
|
450 | 452 | @skipUnless(SERVER_VERSION >= (3, 1), "Bookmarking is not supported by this version of Neo4j")
|
451 | 453 | def test_can_obtain_bookmark_after_commit(self):
|
452 |
| - from neo4j.util import watch |
453 |
| - watch("neo4j.bolt") |
454 | 454 | with self.driver.session() as session:
|
455 | 455 | with session.begin_transaction() as tx:
|
456 | 456 | tx.run("RETURN 1")
|
457 | 457 | assert session.last_bookmark is not None
|
458 | 458 |
|
| 459 | + @skipUnless(SERVER_VERSION >= (3, 1), "Bookmarking is not supported by this version of Neo4j") |
| 460 | + def test_can_pass_bookmark_into_next_transaction(self): |
| 461 | + unique_id = uuid4().hex |
| 462 | + |
| 463 | + with self.driver.session(WRITE_ACCESS) as session: |
| 464 | + with session.begin_transaction() as tx: |
| 465 | + tx.run("CREATE (a:Thing {uuid:$uuid})", uuid=unique_id) |
| 466 | + bookmark = session.last_bookmark |
| 467 | + |
| 468 | + assert bookmark is not None |
| 469 | + |
| 470 | + with self.driver.session(READ_ACCESS) as session: |
| 471 | + with session.begin_transaction(bookmark) as tx: |
| 472 | + result = tx.run("MATCH (a:Thing {uuid:$uuid}) RETURN a", uuid=unique_id) |
| 473 | + record_list = list(result) |
| 474 | + assert len(record_list) == 1 |
| 475 | + record = record_list[0] |
| 476 | + assert len(record) == 1 |
| 477 | + thing = record[0] |
| 478 | + assert isinstance(thing, Node) |
| 479 | + assert thing["uuid"] == unique_id |
| 480 | + |
459 | 481 |
|
460 | 482 | class ResultConsumptionTestCase(ServerTestCase):
|
461 | 483 |
|
|
0 commit comments