def test_autocommit_transactions_should_support_timeout(neo4j_driver): with neo4j_driver.session() as s1: s1.run("CREATE (a:Node)").consume() with neo4j_driver.session() as s2: tx1 = s1.begin_transaction() tx1.run("MATCH (a:Node) SET a.property = 1").consume() with raises(TransientError): s2.run( Statement("MATCH (a:Node) SET a.property = 2", timeout=0.25)).consume()
def test_autocommit_transactions_should_support_metadata(session): metadata_in = {"foo": "bar"} try: statement = Statement("CALL dbms.getTXMetaData", metadata=metadata_in) metadata_out = session.run(statement).single().value() except ClientError as e: if e.code == "Neo.ClientError.Procedure.ProcedureNotFound": raise SkipTest("Cannot assert correct metadata as Neo4j edition " "does not support procedure dbms.getTXMetaData") else: raise else: assert metadata_in == metadata_out
def test_autocommit_transactions_should_support_metadata( session, test_input, neo4j_version): # python -m pytest tests/integration/test_autocommit.py -s -r fEsxX -k test_autocommit_transactions_should_support_metadata metadata_in = {"foo": "bar"} result = session.run("RETURN 1") value = result.single().value() summary = result.summary() server_agent = summary.server.agent try: statement = Statement(test_input, metadata=metadata_in) result = session.run(statement) metadata_out = result.single().value() except ClientError as e: if e.code == "Neo.ClientError.Procedure.ProcedureNotFound": pytest.skip( "Cannot assert correct metadata as {} does not support procedure '{}' introduced in Neo4j {}" .format(server_agent, test_input, neo4j_version)) else: raise else: assert metadata_in == metadata_out
def add_person_within_a_second(self, name): with self.driver.session() as session: session.run(Statement("CREATE (a:Person {name: $name})", timeout=1.0), name=name)
def test_statement_object(session): value = session.run(Statement("RETURN $x"), x=1).single().value() assert value == 1
def test_statement_object_not_supported(session): with session.begin_transaction() as tx: with raises(ValueError): tx.run(Statement("RETURN 1", timeout=0.25))