Skip to content

Commit 93ae985

Browse files
committed
Bookmark tests
1 parent 60bf7be commit 93ae985

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

test/test_session.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020

2121
from mock import patch
2222
from unittest import skipUnless
23+
from uuid import uuid4
2324

25+
from neo4j.v1 import READ_ACCESS, WRITE_ACCESS
2426
from neo4j.v1.exceptions import CypherError, ResultError
2527
from neo4j.v1.session import GraphDatabase, basic_auth, Record
2628
from neo4j.v1.types import Node, Relationship, Path
@@ -449,13 +451,33 @@ def tearDown(self):
449451

450452
@skipUnless(SERVER_VERSION >= (3, 1), "Bookmarking is not supported by this version of Neo4j")
451453
def test_can_obtain_bookmark_after_commit(self):
452-
from neo4j.util import watch
453-
watch("neo4j.bolt")
454454
with self.driver.session() as session:
455455
with session.begin_transaction() as tx:
456456
tx.run("RETURN 1")
457457
assert session.last_bookmark is not None
458458

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+
459481

460482
class ResultConsumptionTestCase(ServerTestCase):
461483

0 commit comments

Comments
 (0)