def test_autocommit_transactions_should_support_timeout(self): with self.driver.session() as s1: s1.run("CREATE (a:Node)").consume() with self.driver.session() as s2: tx1 = s1.begin_transaction() tx1.run("MATCH (a:Node) SET a.property = 1").consume() with self.assertRaises(TransientError): s2.run(Statement("MATCH (a:Node) SET a.property = 2", timeout=0.25)).consume()
def test_autocommit_transactions_should_support_metadata(self): metadata_in = {"foo": "bar"} with self.driver.session() as session: try: metadata_out = session.run(Statement("CALL dbms.getTXMetaData", metadata=metadata_in)).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: self.assertEqual(metadata_in, metadata_out)
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_statement_object_not_supported(self): with self.driver.session() as session: with session.begin_transaction() as tx: with self.assertRaises(ValueError): tx.run(Statement("RETURN 1", timeout=0.25))
def test_statement_object(self): with self.driver.session() as session: value = session.run(Statement("RETURN $x"), x=1).single().value() self.assertEqual(value, 1)
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(self): if self.protocol_version() < 3: raise SkipTest("Test requires Bolt v3") with self.driver.session() as session: value = session.run(Statement("RETURN $x"), x=1).single().value() self.assertEqual(value, 1)
def test_statement_object(session): value = session.run(Statement("RETURN $x"), x=1).single().value() assert value == 1