From 9e357ef3d53b96789b4591011bba7d6fad3d3e43 Mon Sep 17 00:00:00 2001 From: Robsdedude Date: Thu, 15 Dec 2022 10:06:30 +0100 Subject: [PATCH] 8th and final round of migrating integration tests from Python (#538) * Rename session.read/write_transaction -> execute_read/write * 8th and final round of migrating integration tests from Python * Protocol: wrap tx metadata in Cypher types --- nutkit/frontend/session.py | 8 +- tests/neo4j/datatypes/_base.py | 6 +- tests/neo4j/datatypes/test_datatypes.py | 6 +- tests/neo4j/datatypes/test_temporal_types.py | 4 +- tests/neo4j/test_authentication.py | 2 +- tests/neo4j/test_bookmarks.py | 6 +- tests/neo4j/test_direct_driver.py | 2 +- tests/neo4j/test_session_run.py | 4 +- tests/neo4j/test_summary.py | 2 +- tests/neo4j/test_tx_func_run.py | 57 ++++++--- tests/neo4j/test_tx_run.py | 10 +- .../stub/authorization/test_authorization.py | 16 +-- tests/stub/bookmarks/test_bookmarks_v4.py | 4 +- .../test_connection_recv_timeout_seconds.py | 4 +- .../test_bookmark_manager.py | 117 ++++++++++++------ tests/stub/homedb/test_homedb.py | 6 +- tests/stub/iteration/test_result_list.py | 4 +- .../iteration/test_result_optional_single.py | 2 +- tests/stub/iteration/test_result_peek.py | 2 +- tests/stub/iteration/test_result_scope.py | 4 +- tests/stub/iteration/test_result_single.py | 2 +- tests/stub/retry/test_retry.py | 11 +- tests/stub/retry/test_retry_clustering.py | 10 +- tests/stub/routing/test_no_routing_v4x1.py | 2 +- tests/stub/routing/test_routing_v5x0.py | 54 ++++---- .../test_session_run_parameters.py | 7 +- .../test_tx_begin_parameters.py | 13 +- tests/stub/tx_run/test_tx_run.py | 4 +- tests/stub/types/test_temporal_types.py | 4 +- 29 files changed, 220 insertions(+), 153 deletions(-) diff --git a/nutkit/frontend/session.py b/nutkit/frontend/session.py index 8f943fb29..f51a0815c 100644 --- a/nutkit/frontend/session.py +++ b/nutkit/frontend/session.py @@ -16,7 +16,7 @@ def close(self, hooks=None): if not isinstance(res, protocol.Session): raise Exception("Should be session but was: %s" % res) - def run(self, cypher, params=None, tx_meta=None, hooks=None, **kwargs): + def run(self, cypher, *, params=None, tx_meta=None, hooks=None, **kwargs): req = protocol.SessionRun(self._session.id, cypher, params, txMeta=tx_meta, **kwargs) res = self._driver.send_and_receive(req, hooks=hooks, @@ -80,21 +80,21 @@ def process_transaction(self, req, fn, config=None, hooks=None): "Should be RetryableTry or RetryableDone but was: %s" % res ) - def read_transaction(self, fn, tx_meta=None, hooks=None, **kwargs): + def execute_read(self, fn, *, tx_meta=None, hooks=None, **kwargs): # Send request to enter transactional read function req = protocol.SessionReadTransaction( self._session.id, txMeta=tx_meta, **kwargs ) return self.process_transaction(req, fn, hooks=hooks) - def write_transaction(self, fn, tx_meta=None, hooks=None, **kwargs): + def execute_write(self, fn, *, tx_meta=None, hooks=None, **kwargs): # Send request to enter transactional read function req = protocol.SessionWriteTransaction( self._session.id, txMeta=tx_meta, **kwargs ) return self.process_transaction(req, fn, hooks=hooks) - def begin_transaction(self, tx_meta=None, hooks=None, **kwargs): + def begin_transaction(self, *, tx_meta=None, hooks=None, **kwargs): req = protocol.SessionBeginTransaction( self._session.id, txMeta=tx_meta, **kwargs ) diff --git a/tests/neo4j/datatypes/_base.py b/tests/neo4j/datatypes/_base.py index 871458e90..f3d7020fa 100644 --- a/tests/neo4j/datatypes/_base.py +++ b/tests/neo4j/datatypes/_base.py @@ -35,7 +35,7 @@ def work(tx): assert isinstance(result.next(), types.NullRecord) return record_ - record = self._session.read_transaction(work) + record = self._session.execute_read(work) self.assertEqual(record, types.Record(values=[val])) def _read_query_values(self, query, params=None): @@ -45,7 +45,7 @@ def work(tx): assert isinstance(result.next(), types.NullRecord) return record_.values - return self._session.read_transaction(work) + return self._session.execute_read(work) def _write_query_values(self, query, params=None): values = [] @@ -60,5 +60,5 @@ def work(tx): raise ApplicationCodeError with self.assertRaises(types.FrontendError): - self._session.write_transaction(work) + self._session.execute_write(work) return values diff --git a/tests/neo4j/datatypes/test_datatypes.py b/tests/neo4j/datatypes/test_datatypes.py index b47e5f9ff..b19df7508 100644 --- a/tests/neo4j/datatypes/test_datatypes.py +++ b/tests/neo4j/datatypes/test_datatypes.py @@ -146,7 +146,7 @@ def work(tx): self._create_driver_and_session() - record = self._session.write_transaction(work) + record = self._session.execute_write(work) self.assertIsInstance(record, types.Record) node = record.values[0] @@ -173,7 +173,7 @@ def work(tx): self._create_driver_and_session() - record = self._session.write_transaction(work) + record = self._session.execute_write(work) self.assertIsInstance(record, types.Record) values = record.values self.assertEqual(len(values), 3) @@ -205,7 +205,7 @@ def work(tx): self._create_driver_and_session() - record = self._session.write_transaction(work) + record = self._session.execute_write(work) self.assertIsInstance(record, types.Record) values = record.values self.assertEqual(len(values), 6) diff --git a/tests/neo4j/datatypes/test_temporal_types.py b/tests/neo4j/datatypes/test_temporal_types.py index d34b18711..3bb5d1c33 100644 --- a/tests/neo4j/datatypes/test_temporal_types.py +++ b/tests/neo4j/datatypes/test_temporal_types.py @@ -101,7 +101,7 @@ def work(tx): assert self._driver and self._session try: - echoed_tz_id = self._session.read_transaction(work) + echoed_tz_id = self._session.execute_read(work) return echoed_tz_id == tz_id except types.DriverError as e: assert tz_id in e.msg @@ -208,7 +208,7 @@ def work(tx): continue with self.subTest(tz_id=tz_id): dt, y, mo, d, h, m, s, ns, offset, tz = \ - self._session.read_transaction(work) + self._session.execute_read(work) cypher_dt = types.CypherDateTime( y, mo, d, h, m, s, ns, offset, tz_id ) diff --git a/tests/neo4j/test_authentication.py b/tests/neo4j/test_authentication.py index 789881be1..caf974879 100644 --- a/tests/neo4j/test_authentication.py +++ b/tests/neo4j/test_authentication.py @@ -37,7 +37,7 @@ def dummy_query(tx_or_session): self.create_driver_and_session(auth_token) if use_tx: - result = self._session.read_transaction(dummy_query) + result = self._session.execute_read(dummy_query) else: result = self._session.run("RETURN 2 as Number") self.assertEqual( diff --git a/tests/neo4j/test_bookmarks.py b/tests/neo4j/test_bookmarks.py index ce24f11cc..fedda7f2f 100644 --- a/tests/neo4j/test_bookmarks.py +++ b/tests/neo4j/test_bookmarks.py @@ -118,7 +118,7 @@ def work(tx): result.next() with self.assertRaises(types.DriverError) as exc: - self._session.read_transaction(work) + self._session.execute_read(work) if get_driver_name() in ["java"]: self.assertEqual( "org.neo4j.driver.exceptions.ClientException", @@ -151,7 +151,7 @@ def create_node(tx): for _ in range(expected_node_count): self._session = self._driver.session("w") - self._session.write_transaction(create_node) + self._session.execute_write(create_node) bookmarks.append(self._session.last_bookmarks()) self._session.close() @@ -167,7 +167,7 @@ def get_node_count(tx): record = result.next() return record.values[0] - count = self._session.read_transaction(get_node_count) + count = self._session.execute_read(get_node_count) self.assertEqual(types.CypherInt(expected_node_count), count) @cluster_unsafe_test diff --git a/tests/neo4j/test_direct_driver.py b/tests/neo4j/test_direct_driver.py index f7cb2f7c5..664734032 100644 --- a/tests/neo4j/test_direct_driver.py +++ b/tests/neo4j/test_direct_driver.py @@ -82,7 +82,7 @@ def work(tx): self._driver = get_driver(self._backend) self._session = self._driver.session("w") - summary = self._session.read_transaction(work) + summary = self._session.execute_read(work) result = self._driver.supports_multi_db() self.assertTrue(result) diff --git a/tests/neo4j/test_session_run.py b/tests/neo4j/test_session_run.py index 5b67231b2..971ae91e1 100644 --- a/tests/neo4j/test_session_run.py +++ b/tests/neo4j/test_session_run.py @@ -132,7 +132,7 @@ def test_autocommit_transactions_should_support_metadata(self): self._session1 = self._driver.session("r") result = self._session1.run( "CALL tx.getMetaData", - tx_meta={k: v.value for k, v in metadata.items()} + tx_meta=metadata ) record = result.next() self.assertIsInstance(record, types.Record) @@ -294,7 +294,7 @@ def test_iteration_nested(self): def run(i, n): return self._session1.run( "UNWIND RANGE ($i, $n) AS x RETURN x", - {"i": types.CypherInt(i), "n": types.CypherInt(n)} + params={"i": types.CypherInt(i), "n": types.CypherInt(n)} ) i0 = 0 n0 = 6 diff --git a/tests/neo4j/test_summary.py b/tests/neo4j/test_summary.py index 11b7c3239..7efe1a14b 100644 --- a/tests/neo4j/test_summary.py +++ b/tests/neo4j/test_summary.py @@ -32,7 +32,7 @@ def work(tx): return summary params = {} if params is None else params self._session = self._driver.session("w") - return self._session.write_transaction(work) + return self._session.execute_write(work) def test_can_obtain_summary_after_consuming_result(self): summary = self.get_summary("CREATE (n) RETURN n") diff --git a/tests/neo4j/test_tx_func_run.py b/tests/neo4j/test_tx_func_run.py index e943793de..f3671bd55 100644 --- a/tests/neo4j/test_tx_func_run.py +++ b/tests/neo4j/test_tx_func_run.py @@ -39,7 +39,7 @@ def _test(): self._driver.close() self._driver = get_driver(self._backend, user_agent="test") self._session1 = self._driver.session("r", fetch_size=2) - self._session1.read_transaction(work) + self._session1.execute_read(work) self._session1.close() self._session1 = None @@ -47,6 +47,30 @@ def _test(): with self.subTest(consume=consume): _test() + def test_parameter(self): + def work(tx): + result = tx.run("RETURN $x", {"x": types.CypherInt(1)}) + self.assertEqual(list(result), + [types.Record([types.CypherInt(1)])]) + + self._session1 = self._driver.session("r") + self._session1.execute_read(work) + + def test_meta_data(self): + metadata = {"foo": types.CypherFloat(1.5), + "bar": types.CypherString("baz")} + + def work(tx): + result = tx.run("CALL tx.getMetaData") + record = result.next() + self.assertIsInstance(record, types.Record) + self.assertEqual(record.values, [types.CypherMap(metadata)]) + + self._session1 = self._driver.session("r") + self._session1.execute_read( + work, tx_meta=metadata, + ) + def test_iteration_nested(self): # Verifies that it is possible to nest results with small fetch sizes # within a transaction function. @@ -57,8 +81,10 @@ def test_iteration_nested(self): self.skipTest("Fails for some reason") def run(tx, i, n): - return tx.run("UNWIND RANGE ($i, $n) AS x RETURN x", - {"i": types.CypherInt(i), "n": types.CypherInt(n)}) + return tx.run( + "UNWIND RANGE ($i, $n) AS x RETURN x", + params={"i": types.CypherInt(i), "n": types.CypherInt(n)} + ) self._session1 = self._driver.session("r", fetch_size=2) @@ -100,7 +126,7 @@ def nested(tx): self.assertEqual(res0.next(), types.NullRecord()) return "done" - x = self._session1.read_transaction(nested) + x = self._session1.execute_read(nested) self.assertEqual(lasts, {0: 6, 1: 11, 2: 1001}) self.assertEqual(x, "done") @@ -112,7 +138,7 @@ def run(tx): tx.run("CREATE (n:SessionNode) RETURN n") self._session1 = self._driver.session("w") - self._session1.write_transaction(run) + self._session1.execute_write(run) bookmarks = self._session1.last_bookmarks() self.assertEqual(len(bookmarks), 1) self.assertGreater(len(bookmarks[0]), 3) @@ -126,7 +152,7 @@ def run(tx): self._session1 = self._driver.session("w") with self.assertRaises(types.FrontendError): - self._session1.write_transaction(run) + self._session1.execute_write(run) bookmarks = self._session1.last_bookmarks() self.assertEqual(len(bookmarks), 0) @@ -151,15 +177,11 @@ def assertion_query(tx): self._session1 = self._driver.session("w") expected_exc = types.FrontendError with self.assertRaises(expected_exc): - self._session1.write_transaction(run) + self._session1.execute_write(run) - self._session1.read_transaction(assertion_query) + self._session1.execute_read(assertion_query) def test_tx_func_configuration(self): - # TODO: remove this block once all languages work - if get_driver_name() in ["java"]: - self.skipTest("Does not send metadata") - def run(tx): values = [] result = tx.run("UNWIND [1,2,3,4] AS x RETURN x") @@ -177,10 +199,7 @@ def run(tx): metadata = {"foo": types.CypherFloat(1.5), "bar": types.CypherString("baz")} self._session1 = self._driver.session("w") - res = self._session1.read_transaction( - run, timeout=3000, - tx_meta={k: v.value for k, v in metadata.items()} - ) + res = self._session1.execute_read(run, timeout=3000, tx_meta=metadata) self.assertEqual(res, list(map(types.CypherInt, range(1, 5)))) def test_tx_timeout(self): @@ -198,7 +217,7 @@ def update1(tx): tx.run("MATCH (a:Node) SET a.property = 1").consume() with self.assertRaises(types.FrontendError): - self._session2.write_transaction(update2, timeout=250) + self._session2.execute_write(update2, timeout=250) def update2(tx): nonlocal exc @@ -215,11 +234,11 @@ def update2(tx): exc = None self._session1 = self._driver.session("w") - db = self._session1.write_transaction(create) + db = self._session1.execute_write(create) self._session2 = self._driver.session( "w", bookmarks=self._session1.last_bookmarks(), database=db ) - self._session1.write_transaction(update1) + self._session1.execute_write(update1) self.assertIsInstance(exc, types.DriverError) self.assertEqual(exc.code, diff --git a/tests/neo4j/test_tx_run.py b/tests/neo4j/test_tx_run.py index 7f9963633..f0f105775 100644 --- a/tests/neo4j/test_tx_run.py +++ b/tests/neo4j/test_tx_run.py @@ -80,8 +80,8 @@ def test_can_commit_transaction(self): tx.commit() # Check the property value - result = self._session1.run("MATCH (a) WHERE id(a) = $n " - "RETURN a.foo", {"n": node_id}) + result = self._session1.run("MATCH (a) WHERE id(a) = $n RETURN a.foo", + params={"n": node_id}) record = result.next() self.assertIsInstance(record, types.Record) self.assertEqual(len(record.values), 1) @@ -109,8 +109,8 @@ def test_can_rollback_transaction(self): tx.rollback() # Check the property value - result = self._session1.run("MATCH (a) WHERE id(a) = $n " - "RETURN a.foo", {"n": node_id}) + result = self._session1.run("MATCH (a) WHERE id(a) = $n RETURN a.foo", + params={"n": node_id}) record = result.next() self.assertIsInstance(record, types.NullRecord) @@ -290,7 +290,7 @@ def test_tx_configuration(self): "bar": types.CypherString("baz")} self._session1 = self._driver.session("r") tx = self._session1.begin_transaction( - tx_meta={k: v.value for k, v in metadata.items()}, timeout=3000 + tx_meta=metadata, timeout=3000 ) result = tx.run("UNWIND [1,2,3,4] AS x RETURN x") values = [] diff --git a/tests/stub/authorization/test_authorization.py b/tests/stub/authorization/test_authorization.py index 9aa09fc03..bb0227c33 100644 --- a/tests/stub/authorization/test_authorization.py +++ b/tests/stub/authorization/test_authorization.py @@ -402,7 +402,7 @@ def work(tx): result = tx.run("RETURN 1 as n") sequences.append(list(result)) - session.read_transaction(work) + session.execute_read(work) session.close() driver.close() @@ -442,7 +442,7 @@ def work(tx): sequences.append(list(result)) with self.assertRaises(types.DriverError) as exc: - session.read_transaction(work) + session.execute_read(work) self.assert_is_token_error(exc.exception) session.close() driver.close() @@ -482,7 +482,7 @@ def work(tx): result = tx.run("RETURN 1 as n") sequences.append(list(result)) - session.read_transaction(work, hooks={ + session.execute_read(work, hooks={ "on_send_RetryableNegative": lambda _: self.switch_unused_servers( (self._read_server1, self._read_server2), "reader_tx.script" ) @@ -523,7 +523,7 @@ def work(tx): sequences.append(list(result)) with self.assertRaises(types.DriverError) as exc: - session.read_transaction(work, hooks={ + session.execute_read(work, hooks={ "on_send_RetryableNegative": lambda _: self.switch_unused_servers( (self._read_server1, self._read_server2), @@ -573,7 +573,7 @@ def work(tx): result = tx.run("RETURN 1 as n") sequences.append(list(result)) - session.read_transaction(work, hooks={ + session.execute_read(work, hooks={ "on_send_RetryableNegative": lambda _: self.switch_unused_servers( (self._read_server1, self._read_server2), "reader_tx.script" ) @@ -612,7 +612,7 @@ def work(tx): sequences.append(list(result)) with self.assertRaises(types.DriverError) as exc: - session.read_transaction(work, hooks={ + session.execute_read(work, hooks={ "on_send_RetryableNegative": lambda _: self.switch_unused_servers( (self._read_server1, self._read_server2), @@ -662,7 +662,7 @@ def work(tx): result = tx.run("RETURN 1 as n") sequences.append(list(result)) - session.read_transaction(work, hooks={ + session.execute_read(work, hooks={ "on_send_RetryablePositive": lambda _: self.switch_unused_servers( (self._read_server1, self._read_server2), "reader_tx.script" ) @@ -702,7 +702,7 @@ def work(tx): sequences.append(list(result)) with self.assertRaises(types.DriverError) as exc: - session.read_transaction(work, hooks={ + session.execute_read(work, hooks={ "on_send_RetryableNegative": lambda _: self.switch_unused_servers( (self._read_server1, self._read_server2), diff --git a/tests/stub/bookmarks/test_bookmarks_v4.py b/tests/stub/bookmarks/test_bookmarks_v4.py index 326725ea1..189f11265 100644 --- a/tests/stub/bookmarks/test_bookmarks_v4.py +++ b/tests/stub/bookmarks/test_bookmarks_v4.py @@ -155,9 +155,9 @@ def test(mode_, bm_count_, check_bms_pre_query_, consume_): sorted(bookmarks)) work = work_consume if consume_ else work_no_consume if mode == "write": - session.write_transaction(work) + session.execute_write(work) else: - session.read_transaction(work) + session.execute_read(work) self.assertEqual(session.last_bookmarks(), ["bm:re"]) session.close() server.done() diff --git a/tests/stub/configuration_hints/test_connection_recv_timeout_seconds.py b/tests/stub/configuration_hints/test_connection_recv_timeout_seconds.py index 1b4910abe..6688ecb0f 100644 --- a/tests/stub/configuration_hints/test_connection_recv_timeout_seconds.py +++ b/tests/stub/configuration_hints/test_connection_recv_timeout_seconds.py @@ -176,7 +176,7 @@ def work(tx): self.assertIsInstance(result.next(), types.NullRecord) self._start_server("1_second_exceeds_tx_retry.script") - self._session.write_transaction(work) + self._session.execute_write(work) self._server.done() self.assertEqual(retries, 2) self.assertIsInstance(record, types.Record) @@ -230,7 +230,7 @@ def work(tx): self.assertIsInstance(result.next(), types.NullRecord) self._start_server("2_seconds_in_time_tx_retry.script") - self._session.write_transaction(work) + self._session.execute_write(work) self._server.done() self.assertEqual(retries, 1) self.assertIsInstance(record, types.Record) diff --git a/tests/stub/driver_parameters/test_bookmark_manager.py b/tests/stub/driver_parameters/test_bookmark_manager.py index 27c615142..1eb0c8347 100644 --- a/tests/stub/driver_parameters/test_bookmark_manager.py +++ b/tests/stub/driver_parameters/test_bookmark_manager.py @@ -78,19 +78,22 @@ def test_should_keep_track_of_tx_in_sequence(self): manager = self._new_bookmark_manager() s1 = self._driver.session("w", bookmark_manager=manager) - tx1 = s1.begin_transaction(tx_meta={"return_bookmark": "bm1"}) + tx_meta = {"return_bookmark": types.CypherString("bm1")} + tx1 = s1.begin_transaction(tx_meta=tx_meta) list(tx1.run("RETURN 1 AS n")) tx1.commit() s1.close() s2 = self._driver.session("w", bookmark_manager=manager) - tx2 = s2.begin_transaction(tx_meta={"return_bookmark": "bm2"}) + tx_meta = {"return_bookmark": types.CypherString("bm2")} + tx2 = s2.begin_transaction(tx_meta=tx_meta) list(tx2.run("RETURN 1 AS n")) tx2.commit() s2.close() s3 = self._driver.session("w", bookmark_manager=manager) - tx3 = s3.begin_transaction(tx_meta={"return_bookmark": "bm2"}) + tx_meta = {"return_bookmark": types.CypherString("bm2")} + tx3 = s3.begin_transaction(tx_meta=tx_meta) list(tx3.run("RETURN 1 AS n")) tx3.commit() s3.close() @@ -117,19 +120,22 @@ def test_should_not_replace_bookmarks_with_empty_bookmarks(self): manager = self._new_bookmark_manager() s1 = self._driver.session("w", bookmark_manager=manager) - tx1 = s1.begin_transaction(tx_meta={"return_bookmark": "bm1"}) + tx_meta = {"return_bookmark": types.CypherString("bm1")} + tx1 = s1.begin_transaction(tx_meta=tx_meta) list(tx1.run("RETURN 1 AS n")) tx1.commit() s1.close() s2 = self._driver.session("r", bookmark_manager=manager) - tx2 = s2.begin_transaction(tx_meta={"return_bookmark": "empty"}) + tx_meta = {"return_bookmark": types.CypherString("empty")} + tx2 = s2.begin_transaction(tx_meta=tx_meta) list(tx2.run("RETURN 1 AS n")) tx2.commit() s2.close() s3 = self._driver.session("w", bookmark_manager=manager) - tx3 = s3.begin_transaction(tx_meta={"return_bookmark": "bm3"}) + tx_meta = {"return_bookmark": types.CypherString("bm3")} + tx3 = s3.begin_transaction(tx_meta=tx_meta) list(tx3.run("RETURN 1 AS n")) tx3.commit() s3.close() @@ -156,11 +162,13 @@ def test_should_keep_track_of_tx_in_parallel(self): manager = self._new_bookmark_manager() s1 = self._driver.session("w", bookmark_manager=manager) - tx1 = s1.begin_transaction(tx_meta={"return_bookmark": "bm1"}) + tx_meta = {"return_bookmark": types.CypherString("bm1")} + tx1 = s1.begin_transaction(tx_meta=tx_meta) list(tx1.run("RETURN 1 AS n")) s2 = self._driver.session("w", bookmark_manager=manager) - tx2 = s2.begin_transaction(tx_meta={"return_bookmark": "bm2"}) + tx_meta = {"return_bookmark": types.CypherString("bm2")} + tx2 = s2.begin_transaction(tx_meta=tx_meta) list(tx2.run("RETURN 1 AS n")) tx1.commit() @@ -169,7 +177,8 @@ def test_should_keep_track_of_tx_in_parallel(self): s2.close() s3 = self._driver.session("w", bookmark_manager=manager) - tx3 = s3.begin_transaction(tx_meta={"return_bookmark": "bm2"}) + tx_meta = {"return_bookmark": types.CypherString("bm2")} + tx3 = s3.begin_transaction(tx_meta=tx_meta) list(tx3.run("RETURN 1 AS n")) tx3.commit() s3.close() @@ -194,13 +203,15 @@ def test_should_manage_explicitly_session_bookmarks(self): manager = self._new_bookmark_manager() s1 = self._driver.session("w", bookmark_manager=manager) - tx1 = s1.begin_transaction(tx_meta={"return_bookmark": "bm1"}) + tx_meta = {"return_bookmark": types.CypherString("bm1")} + tx1 = s1.begin_transaction(tx_meta=tx_meta) list(tx1.run("RETURN 1 AS n")) tx1.commit() s1.close() s2 = self._driver.session("w", bookmarks=[], bookmark_manager=manager) - tx2 = s2.begin_transaction(tx_meta={"return_bookmark": "bm2"}) + tx_meta = {"return_bookmark": types.CypherString("bm2")} + tx2 = s2.begin_transaction(tx_meta=tx_meta) list(tx2.run("RETURN 1 AS n")) tx2.commit() s2.close() @@ -210,13 +221,15 @@ def test_should_manage_explicitly_session_bookmarks(self): bookmarks=["bm2", "unmanaged"], bookmark_manager=manager ) - tx3 = s3.begin_transaction(tx_meta={"return_bookmark": "bm3"}) + tx_meta = {"return_bookmark": types.CypherString("bm3")} + tx3 = s3.begin_transaction(tx_meta=tx_meta) list(tx3.run("RETURN 1 AS n")) tx3.commit() s3.close() s4 = self._driver.session("w", bookmark_manager=manager) - tx4 = s4.begin_transaction(tx_meta={"return_bookmark": "bm3"}) + tx_meta = {"return_bookmark": types.CypherString("bm3")} + tx4 = s4.begin_transaction(tx_meta=tx_meta) list(tx4.run("RETURN 1 AS n")) tx4.commit() s4.close() @@ -247,13 +260,15 @@ def test_should_ignore_bookmark_manager_not_set_in_a_session(self): manager = self._new_bookmark_manager() s1 = self._driver.session("w", bookmark_manager=manager) - tx1 = s1.begin_transaction(tx_meta={"return_bookmark": "bm1"}) + tx_meta = {"return_bookmark": types.CypherString("bm1")} + tx1 = s1.begin_transaction(tx_meta=tx_meta) list(tx1.run("RETURN 1 AS n")) tx1.commit() s1.close() s2 = self._driver.session("w") - tx2 = s2.begin_transaction(tx_meta={"return_bookmark": "bm2"}) + tx_meta = {"return_bookmark": types.CypherString("bm2")} + tx2 = s2.begin_transaction(tx_meta=tx_meta) list(tx2.run("RETURN 1 AS n")) tx2.commit() s2.close() @@ -262,13 +277,15 @@ def test_should_ignore_bookmark_manager_not_set_in_a_session(self): "w", bookmarks=["unmanaged"] ) - tx3 = s3.begin_transaction(tx_meta={"return_bookmark": "bm3"}) + tx_meta = {"return_bookmark": types.CypherString("bm3")} + tx3 = s3.begin_transaction(tx_meta=tx_meta) list(tx3.run("RETURN 1 AS n")) tx3.commit() s3.close() s4 = self._driver.session("w", bookmark_manager=manager) - tx4 = s4.begin_transaction(tx_meta={"return_bookmark": "bm3"}) + tx_meta = {"return_bookmark": types.CypherString("bm3")} + tx4 = s4.begin_transaction(tx_meta=tx_meta) list(tx4.run("RETURN 1 AS n")) tx4.commit() s4.close() @@ -305,7 +322,8 @@ def test_should_use_initial_bookmark_set_in_the_first_tx(self): database="neo4j", bookmark_manager=manager ) - tx1 = s1.begin_transaction(tx_meta={"return_bookmark": "bm1"}) + tx_meta = {"return_bookmark": types.CypherString("bm1")} + tx1 = s1.begin_transaction(tx_meta=tx_meta) list(tx1.run("RETURN 1 AS n")) tx1.commit() s1.close() @@ -315,7 +333,8 @@ def test_should_use_initial_bookmark_set_in_the_first_tx(self): database="neo4j", bookmark_manager=manager ) - tx2 = s2.begin_transaction(tx_meta={"return_bookmark": "bm2"}) + tx_meta = {"return_bookmark": types.CypherString("bm2")} + tx2 = s2.begin_transaction(tx_meta=tx_meta) list(tx2.run("RETURN 1 AS n")) tx2.commit() s2.close() @@ -348,7 +367,8 @@ def test_should_send_all_bookmarks_and_replace_it_by_the_new_one(self): database="neo4j", bookmark_manager=manager ) - tx1 = s1.begin_transaction(tx_meta={"return_bookmark": "bm1"}) + tx_meta = {"return_bookmark": types.CypherString("bm1")} + tx1 = s1.begin_transaction(tx_meta=tx_meta) list(tx1.run("RETURN 1 AS n")) tx1.commit() s1.close() @@ -358,7 +378,8 @@ def test_should_send_all_bookmarks_and_replace_it_by_the_new_one(self): database="neo4j", bookmark_manager=manager ) - tx2 = s2.begin_transaction(tx_meta={"return_bookmark": "bm2"}) + tx_meta = {"return_bookmark": types.CypherString("bm2")} + tx2 = s2.begin_transaction(tx_meta=tx_meta) list(tx2.run("RETURN 1 AS n")) tx2.commit() s2.close() @@ -388,7 +409,8 @@ def test_should_handle_database_redirection_in_tx(self): database="neo4j", bookmark_manager=manager ) - tx1 = s1.begin_transaction(tx_meta={"return_bookmark": "bm1"}) + tx_meta = {"return_bookmark": types.CypherString("bm1")} + tx1 = s1.begin_transaction(tx_meta=tx_meta) list(tx1.run("RETURN 1 AS n")) tx1.commit() s1.close() @@ -398,7 +420,8 @@ def test_should_handle_database_redirection_in_tx(self): database="neo4j", bookmark_manager=manager ) - tx2 = s2.begin_transaction(tx_meta={"order": "adb"}) + tx_meta = {"order": types.CypherString("adb")} + tx2 = s2.begin_transaction(tx_meta=tx_meta) list(tx2.run("USE adb RETURN 1 AS n")) tx2.commit() s2.close() @@ -408,7 +431,8 @@ def test_should_handle_database_redirection_in_tx(self): database="neo4j", bookmark_manager=manager ) - tx3 = s3.begin_transaction(tx_meta={"return_bookmark": "bm2"}) + tx_meta = {"return_bookmark": types.CypherString("bm2")} + tx3 = s3.begin_transaction(tx_meta=tx_meta) list(tx3.run("RETURN 1 AS n")) tx3.commit() s3.close() @@ -418,7 +442,8 @@ def test_should_handle_database_redirection_in_tx(self): database="neo4j", bookmark_manager=manager ) - tx4 = s4.begin_transaction(tx_meta={"return_bookmark": "bm3"}) + tx_meta = {"return_bookmark": types.CypherString("bm3")} + tx4 = s4.begin_transaction(tx_meta=tx_meta) list(tx4.run("RETURN 1 AS n")) tx4.commit() s4.close() @@ -495,13 +520,15 @@ def test_should_resolve_database_name_with_bookmarks(self): ) s1 = self._driver.session("w", bookmark_manager=manager) - tx1 = s1.begin_transaction(tx_meta={"return_bookmark": "bm1"}) + tx_meta = {"return_bookmark": types.CypherString("bm1")} + tx1 = s1.begin_transaction(tx_meta=tx_meta) list(tx1.run("RETURN 1 AS n")) tx1.commit() s1.close() s2 = self._driver.session("w", bookmark_manager=manager) - tx2 = s2.begin_transaction(tx_meta={"return_bookmark": "bm2"}) + tx_meta = {"return_bookmark": types.CypherString("bm2")} + tx2 = s2.begin_transaction(tx_meta=tx_meta) list(tx2.run("RETURN 1 AS n")) tx2.commit() s2.close() @@ -549,13 +576,15 @@ def get_bookmarks(): database="neo4j", bookmark_manager=manager ) - tx1 = s1.begin_transaction(tx_meta={"return_bookmark": "bm1"}) + tx_meta = {"return_bookmark": types.CypherString("bm1")} + tx1 = s1.begin_transaction(tx_meta=tx_meta) list(tx1.run("RETURN 1 AS n")) tx1.commit() s1.close() s2 = self._driver.session("w", bookmark_manager=manager) - tx2 = s2.begin_transaction(tx_meta={"return_bookmark": "bm2"}) + tx_meta = {"return_bookmark": types.CypherString("bm2")} + tx2 = s2.begin_transaction(tx_meta=tx_meta) list(tx2.run("RETURN 1 AS n")) tx2.commit() s2.close() @@ -621,7 +650,8 @@ def get_bookmarks(): database="neo4j", bookmark_manager=manager ) - tx1 = s1.begin_transaction(tx_meta={"return_bookmark": "empty"}) + tx_meta = {"return_bookmark": types.CypherString("empty")} + tx1 = s1.begin_transaction(tx_meta=tx_meta) list(tx1.run("RETURN 1 AS n")) tx1.commit() s1.close() @@ -631,7 +661,8 @@ def get_bookmarks(): database="neo4j", bookmark_manager=manager ) - tx2 = s2.begin_transaction(tx_meta={"return_bookmark": "bm1"}) + tx_meta = {"return_bookmark": types.CypherString("bm1")} + tx2 = s2.begin_transaction(tx_meta=tx_meta) list(tx2.run("RETURN 1 AS n")) tx2.commit() s2.close() @@ -641,7 +672,8 @@ def get_bookmarks(): database="neo4j", bookmark_manager=manager ) - tx3 = s3.begin_transaction(tx_meta={"return_bookmark": "bm2"}) + tx_meta = {"return_bookmark": types.CypherString("bm2")} + tx3 = s3.begin_transaction(tx_meta=tx_meta) list(tx3.run("RETURN 1 AS n")) tx3.commit() s3.close() @@ -681,13 +713,15 @@ def bookmarks_consumer(bookmarks): database="neo4j", bookmark_manager=manager ) - tx1 = s1.begin_transaction(tx_meta={"return_bookmark": "bm1"}) + tx_meta = {"return_bookmark": types.CypherString("bm1")} + tx1 = s1.begin_transaction(tx_meta=tx_meta) list(tx1.run("RETURN 1 AS n")) tx1.commit() s1.close() s2 = self._driver.session("w", bookmark_manager=manager) - tx2 = s2.begin_transaction(tx_meta={"order": "adb"}) + tx_meta = {"order": types.CypherString("adb")} + tx2 = s2.begin_transaction(tx_meta=tx_meta) list(tx2.run("USE adb RETURN 1 AS n")) tx2.commit() s2.close() @@ -721,7 +755,8 @@ def bookmarks_consumer(bookmarks): ) s1 = self._driver.session("w", bookmark_manager=manager) - tx1 = s1.begin_transaction(tx_meta={"return_bookmark": "bm1"}) + tx_meta = {"return_bookmark": types.CypherString("bm1")} + tx1 = s1.begin_transaction(tx_meta=tx_meta) list(tx1.run("RETURN 1 AS n")) tx1.commit() s1.close() @@ -753,25 +788,29 @@ def test_multiple_bookmark_manager(self): ) manager1_s1 = self._driver.session("w", bookmark_manager=manager1) - tx1 = manager1_s1.begin_transaction(tx_meta={"return_bookmark": "bm1"}) + tx_meta = {"return_bookmark": types.CypherString("bm1")} + tx1 = manager1_s1.begin_transaction(tx_meta=tx_meta) list(tx1.run("RETURN 1 AS n")) tx1.commit() manager1_s1.close() manager2_s1 = self._driver.session("w", bookmark_manager=manager2) - tx2 = manager2_s1.begin_transaction(tx_meta={"return_bookmark": "bm2"}) + tx_meta = {"return_bookmark": types.CypherString("bm2")} + tx2 = manager2_s1.begin_transaction(tx_meta=tx_meta) list(tx2.run("RETURN 1 AS n")) tx2.commit() manager2_s1.close() manager2_s2 = self._driver.session("w", bookmark_manager=manager2) - tx3 = manager2_s2.begin_transaction(tx_meta={"return_bookmark": "bm3"}) + tx_meta = {"return_bookmark": types.CypherString("bm3")} + tx3 = manager2_s2.begin_transaction(tx_meta=tx_meta) list(tx3.run("RETURN 1 AS n")) tx3.commit() manager2_s2.close() manager1_s2 = self._driver.session("w", bookmark_manager=manager1) - tx4 = manager1_s2.begin_transaction(tx_meta={"return_bookmark": "bm4"}) + tx_meta = {"return_bookmark": types.CypherString("bm4")} + tx4 = manager1_s2.begin_transaction(tx_meta=tx_meta) list(tx4.run("RETURN 1 AS n")) tx4.commit() manager1_s2.close() diff --git a/tests/stub/homedb/test_homedb.py b/tests/stub/homedb/test_homedb.py index 8aaf0e947..9afbd8ce0 100644 --- a/tests/stub/homedb/test_homedb.py +++ b/tests/stub/homedb/test_homedb.py @@ -130,7 +130,7 @@ def work(tx): session1 = driver.session("r", impersonated_user="the-imposter") query = "RETURN 1" - session1.read_transaction(work) + session1.execute_read(work) if not parallel_sessions: session1.close() @@ -138,7 +138,7 @@ def work(tx): "r", bookmarks=["bookmark"], impersonated_user="the-imposter" ) query = "RETURN 2" - session2.read_transaction(work) + session2.execute_read(work) session2.close() if parallel_sessions: session1.close() @@ -190,7 +190,7 @@ def work(tx): ) session = driver.session("r", impersonated_user="the-imposter") - session.read_transaction(work) + session.execute_read(work) session.close() driver.close() diff --git a/tests/stub/iteration/test_result_list.py b/tests/stub/iteration/test_result_list.py index 32f652ee4..b980e7065 100644 --- a/tests/stub/iteration/test_result_list.py +++ b/tests/stub/iteration/test_result_list.py @@ -111,7 +111,7 @@ def work(tx): with self._session("tx_error_on_pull.script", vars_={"#ERROR#": err}) as session: - records = session.read_transaction(work) + records = session.execute_read(work) self.assertEqual(records, [ types.Record(values=[types.CypherInt(1)]) ]) @@ -213,4 +213,4 @@ def work(tx): next_first=next_first) with self._session(script, fetch_size=2) as session: - session.read_transaction(work) + session.execute_read(work) diff --git a/tests/stub/iteration/test_result_optional_single.py b/tests/stub/iteration/test_result_optional_single.py index 7ee00c46b..0b91e1534 100644 --- a/tests/stub/iteration/test_result_optional_single.py +++ b/tests/stub/iteration/test_result_optional_single.py @@ -113,7 +113,7 @@ def work(tx): with self._session("tx_error_on_pull.script", vars_={"#ERROR#": err}) as session: - optional_record = session.read_transaction(work) + optional_record = session.execute_read(work) record, warnings = optional_record.record, optional_record.warnings self.assertIsInstance(record, types.Record) self.assertEqual(record.values, [types.CypherInt(1)]) diff --git a/tests/stub/iteration/test_result_peek.py b/tests/stub/iteration/test_result_peek.py index 43671f052..ca6585837 100644 --- a/tests/stub/iteration/test_result_peek.py +++ b/tests/stub/iteration/test_result_peek.py @@ -129,6 +129,6 @@ def work(tx): with self._session("tx_error_on_pull.script", vars_={"#ERROR#": err}) as session: - record = session.read_transaction(work) + record = session.execute_read(work) self.assertIsInstance(record, types.Record) self.assertEqual(record.values, [types.CypherInt(1)]) diff --git a/tests/stub/iteration/test_result_scope.py b/tests/stub/iteration/test_result_scope.py index 62ed28459..767b380e6 100644 --- a/tests/stub/iteration/test_result_scope.py +++ b/tests/stub/iteration/test_result_scope.py @@ -92,7 +92,7 @@ def _test(result_method_): with self._start_session( "tx_inf_results_until_end.script" ) as session: - result = session.read_transaction(work) + result = session.execute_read(work) with self.assertRaises(types.DriverError) as exc: if result_method_ == "peek": result.peek() @@ -128,7 +128,7 @@ def test(): with self._start_session( "tx_inf_results_until_end.script" ) as session: - session.read_transaction(work) + session.execute_read(work) self._server.done() for result_method in ("next", "peek"): diff --git a/tests/stub/iteration/test_result_single.py b/tests/stub/iteration/test_result_single.py index e1e3ad5fb..f60494e7a 100644 --- a/tests/stub/iteration/test_result_single.py +++ b/tests/stub/iteration/test_result_single.py @@ -124,6 +124,6 @@ def work(tx): with self._session("tx_error_on_pull.script", vars_={"#ERROR#": err}) as session: - record = session.read_transaction(work) + record = session.execute_read(work) self.assertIsInstance(record, types.Record) self.assertEqual(record.values, [types.CypherInt(1)]) diff --git a/tests/stub/retry/test_retry.py b/tests/stub/retry/test_retry.py index 01870abd5..1593bcb48 100644 --- a/tests/stub/retry/test_retry.py +++ b/tests/stub/retry/test_retry.py @@ -38,7 +38,7 @@ def once(tx): driver = Driver(self._backend, "bolt://%s" % self._server.address, auth) session = driver.session("r") - x = session.read_transaction(once) + x = session.execute_read(once) self.assertIsInstance(x, types.CypherInt) self.assertEqual(x.value, 1) self.assertEqual(num_retries, 1) @@ -76,7 +76,7 @@ def twice(tx): driver = Driver(self._backend, "bolt://%s" % self._server.address, auth) session = driver.session("r") - x = session.write_transaction(twice) + x = session.execute_write(twice) self.assertIsInstance(x, types.CypherInt) self.assertEqual(x.value, 1) self.assertEqual(num_retries, 2) @@ -115,13 +115,14 @@ def once(tx): num_retries = num_retries + 1 result = tx.run("RETURN 1") result.next() + auth = types.AuthorizationToken("basic", principal="", credentials="") driver = Driver(self._backend, "bolt://%s" % self._server.address, auth) session = driver.session("w") with self.assertRaises(types.DriverError) as e: # Check further... - session.write_transaction(once) + session.execute_write(once) if get_driver_name() in ["python"]: self.assertEqual( "", @@ -159,7 +160,7 @@ def once(tx): session = driver.session(mode[0]) with self.assertRaises(types.DriverError): # TODO: check further - getattr(session, mode + "_transaction")(once) + getattr(session, "execute_" + mode)(once) # TODO: remove the condition when go sends the error code if get_driver_name() not in ["go"]: self.assertEqual(exception.code, @@ -199,7 +200,7 @@ def once(tx): session = driver.session("w") with self.assertRaises(types.DriverError) as exc: - session.write_transaction(once) + session.execute_write(once) self.assertEqual(exc.exception.code, failure[1]) diff --git a/tests/stub/retry/test_retry_clustering.py b/tests/stub/retry/test_retry_clustering.py index f9a804d3b..a2e10fb4b 100644 --- a/tests/stub/retry/test_retry_clustering.py +++ b/tests/stub/retry/test_retry_clustering.py @@ -48,7 +48,7 @@ def once(tx): driver = Driver(self._backend, self._uri, self._auth, self._userAgent) session = driver.session("r") - x = session.read_transaction(once) + x = session.execute_read(once) self.assertIsInstance(x, types.CypherInt) self.assertEqual(x.value, 1) self.assertEqual(num_retries, 1) @@ -99,7 +99,7 @@ def once(tx): session = driver.session("w") with self.assertRaises(types.DriverError) as e: # Check further... - session.write_transaction(once) + session.execute_write(once) if get_driver_name() in ["python"]: self.assertEqual( "", @@ -175,7 +175,7 @@ def twice(tx): driver = Driver(self._backend, self._uri, self._auth, self._userAgent) session = driver.session("r") - x = session.write_transaction(twice) + x = session.execute_write(twice) self.assertIsInstance(x, types.CypherInt) self.assertEqual(x.value, 1) self.assertEqual(num_retries, 2) @@ -213,7 +213,7 @@ def once(tx): session = driver.session("w") with self.assertRaises(types.DriverError) as exc: - session.write_transaction(once) + session.execute_write(once) self.assertEqual(exc.exception.code, failure[1]) @@ -270,7 +270,7 @@ def twice(tx): driver = Driver(self._backend, self._uri, self._auth, self._userAgent) session = driver.session("r") - x = session.write_transaction(twice) + x = session.execute_write(twice) self.assertIsInstance(x, types.CypherInt) self.assertEqual(x.value, 1) self.assertEqual(num_retries, 2) diff --git a/tests/stub/routing/test_no_routing_v4x1.py b/tests/stub/routing/test_no_routing_v4x1.py index 04d79fce5..195e1eede 100644 --- a/tests/stub/routing/test_no_routing_v4x1.py +++ b/tests/stub/routing/test_no_routing_v4x1.py @@ -574,7 +574,7 @@ def work(tx): result = tx.run("RETURN 1 as n") records = list(result) - session.read_transaction(work) + session.execute_read(work) session.close() driver.close() diff --git a/tests/stub/routing/test_routing_v5x0.py b/tests/stub/routing/test_routing_v5x0.py index fc283f6ec..a4e6d35c4 100644 --- a/tests/stub/routing/test_routing_v5x0.py +++ b/tests/stub/routing/test_routing_v5x0.py @@ -201,7 +201,7 @@ def work(tx): sequences.append(self.collect_records(result)) summaries.append(result.consume()) - session.read_transaction(work) + session.execute_read(work) session.close() driver.close() @@ -344,7 +344,7 @@ def work(tx): tx.commit() with self.assertRaises(types.DriverError) as exc: - session.read_transaction(work) + session.execute_read(work) session.close() driver.close() @@ -400,7 +400,7 @@ def work(tx): tx.commit() with self.assertRaises(types.DriverError) as exc: - session.write_transaction(work) + session.execute_write(work) session.close() driver.close() @@ -497,7 +497,7 @@ def work(tx): list(res) summary = res.consume() - session.write_transaction(work) + session.execute_write(work) session.close() driver.close() @@ -538,7 +538,7 @@ def work(tx): # the tx function will be called 3 times in total work_count = 2 - session.write_transaction(work) + session.execute_write(work) session.close() driver.close() @@ -578,7 +578,7 @@ def work(tx): result = tx.run("RETURN 1 as n") sequences.append(self.collect_records(result)) - session.write_transaction(work) + session.execute_write(work) session.close() driver.close() @@ -634,7 +634,7 @@ def work(tx): result = tx.run("RETURN 1 as n") sequences.append(self.collect_records(result)) - session.write_transaction(work) + session.execute_write(work) session.close() driver.close() @@ -1284,7 +1284,7 @@ def work(tx): self.start_server(working_reader, "reader_tx.script") raise - session.read_transaction(work) + session.execute_read(work) session.close() driver.close() @@ -1333,7 +1333,7 @@ def work(tx): result = tx.run("RETURN 1 as n") sequences.append(self.collect_records(result)) - session.read_transaction(work) + session.execute_read(work) self._routingServer1.done() connection_counts = ( self._readServer1.count_responses(""), @@ -1347,7 +1347,7 @@ def work(tx): self.assertEqual([[1]], sequences) self.assertEqual(1, try_count) - session.read_transaction(work) + session.execute_read(work) session.close() driver.close() @@ -1395,7 +1395,7 @@ def work(tx): self.start_server(working_writer, "writer_tx.script") raise - session.write_transaction(work) + session.execute_write(work) session.close() driver.close() @@ -1444,7 +1444,7 @@ def work(tx): result = tx.run("RETURN 1 as n") sequences.append(self.collect_records(result)) - session.write_transaction(work) + session.execute_write(work) self._routingServer1.done() connection_counts = ( self._writeServer1.count_responses(""), @@ -1458,7 +1458,7 @@ def work(tx): self.assertEqual([[]], sequences) self.assertEqual(1, try_count) - session.write_transaction(work) + session.execute_write(work) session.close() driver.close() @@ -1500,7 +1500,7 @@ def work(tx): result = tx.run("RETURN 1 as n") sequences.append(self.collect_records(result)) - session.read_transaction(work) + session.execute_read(work) session.close() driver.close() @@ -1560,7 +1560,7 @@ def work(tx): result = tx.run("RETURN 1 as n") sequences.append(self.collect_records(result)) - session.write_transaction(work) + session.execute_write(work) session.close() driver.close() @@ -1617,7 +1617,7 @@ def work(tx): result = tx.run("RETURN 1 as n") sequences.append(self.collect_records(result)) - session.read_transaction(work) + session.execute_read(work) session.close() driver.close() @@ -1656,7 +1656,7 @@ def work(tx): result = tx.run("RETURN 1 as n") sequences.append(self.collect_records(result)) - session.read_transaction(work) + session.execute_read(work) session.close() driver.close() @@ -1693,7 +1693,7 @@ def work(tx): result = tx.run("RETURN 1 as n") sequences.append(self.collect_records(result)) - session.read_transaction(work) + session.execute_read(work) session.close() driver.close() @@ -1727,7 +1727,7 @@ def work(tx): result = tx.run("RETURN 1 as n") sequences.append(self.collect_records(result)) - session.read_transaction(work) + session.execute_read(work) failed = False try: @@ -1786,7 +1786,7 @@ def work(tx): result = tx.run("RETURN 1 as n") sequences.append(self.collect_records(result)) - session.read_transaction(work) + session.execute_read(work) list(session.run("RETURN 1 as n")) session.close() driver.close() @@ -1913,7 +1913,7 @@ def work(tx): result = tx.run("RETURN 1 as n") sequences.append(self.collect_records(result)) - session.write_transaction(work) + session.execute_write(work) session.close() driver.close() @@ -1964,7 +1964,7 @@ def on_retryable_negative(_): ) retried = True - session.write_transaction(work, hooks={ + session.execute_write(work, hooks={ "on_send_RetryableNegative": on_retryable_negative }) session.close() @@ -2011,8 +2011,8 @@ def work(tx): result = tx.run("RETURN 1 as n") sequences.append(self.collect_records(result)) - session.read_transaction(work) - session.read_transaction(work) + session.execute_read(work) + session.execute_read(work) session.close() driver.close() @@ -2054,7 +2054,7 @@ def work(tx): result = tx.run("RETURN 1 as n") sequences.append(self.collect_records(result)) - session.read_transaction(work) + session.execute_read(work) session.close() driver.close() @@ -3035,8 +3035,8 @@ def write(tx): session = driver.session("w", database=self.adb) - read_summary = session.read_transaction(read) - write_summary = session.write_transaction(write) + read_summary = session.execute_read(read) + write_summary = session.execute_write(write) self.assertNotEqual(read_summary.server_info.address, write_summary.server_info.address) diff --git a/tests/stub/session_run_parameters/test_session_run_parameters.py b/tests/stub/session_run_parameters/test_session_run_parameters.py index 938d76968..d7e9aef22 100644 --- a/tests/stub/session_run_parameters/test_session_run_parameters.py +++ b/tests/stub/session_run_parameters/test_session_run_parameters.py @@ -116,7 +116,9 @@ def test_tx_meta(self): with self.subTest(routing=routing): self._run("tx_meta", routing, session_args=("w",), - run_kwargs={"tx_meta": {"akey": "aval"}}) + run_kwargs={ + "tx_meta": {"akey": types.CypherString("aval")} + }) @driver_feature(types.Feature.BOLT_4_4) def test_timeout(self): @@ -209,7 +211,8 @@ def test_combined(self): }, run_kwargs={ "params": {"p": types.CypherInt(1)}, - "tx_meta": {"k": "v"}, "timeout": 11 + "tx_meta": {"k": types.CypherString("v")}, + "timeout": 11 }) @driver_feature(types.Feature.BOLT_4_4) diff --git a/tests/stub/tx_begin_parameters/test_tx_begin_parameters.py b/tests/stub/tx_begin_parameters/test_tx_begin_parameters.py index 04baa0f8b..614e7edde 100644 --- a/tests/stub/tx_begin_parameters/test_tx_begin_parameters.py +++ b/tests/stub/tx_begin_parameters/test_tx_begin_parameters.py @@ -86,9 +86,9 @@ def work(tx_): work(tx) tx.commit() elif tx_func_access_mode == "w": - session.write_transaction(work, *tx_args, **tx_kwargs) + session.execute_write(work, *tx_args, **tx_kwargs) elif tx_func_access_mode == "r": - session.read_transaction(work, *tx_args, **tx_kwargs) + session.execute_read(work, *tx_args, **tx_kwargs) else: raise ValueError(tx_func_access_mode) self._server.done() @@ -155,7 +155,9 @@ def test_tx_meta(self): with self.subTest(routing=routing): self._run("tx_meta", routing, session_args=("w",), - tx_kwargs={"tx_meta": {"akey": "aval"}}) + tx_kwargs={ + "tx_meta": {"akey": types.CypherString("aval")} + }) @driver_feature(types.Feature.BOLT_4_4) def test_timeout(self): @@ -249,4 +251,7 @@ def test_combined(self): "database": "adb", "impersonated_user": "that-other-dude" }, - tx_kwargs={"tx_meta": {"k": "v"}, "timeout": 11}) + tx_kwargs={ + "tx_meta": {"k": types.CypherString("v")}, + "timeout": 11 + }) diff --git a/tests/stub/tx_run/test_tx_run.py b/tests/stub/tx_run/test_tx_run.py index 37185968c..5dafd6808 100644 --- a/tests/stub/tx_run/test_tx_run.py +++ b/tests/stub/tx_run/test_tx_run.py @@ -132,7 +132,7 @@ def work(tx): self._session = self._driver.session("w") exc = None try: - self._session.write_transaction(work) + self._session.execute_write(work) except types.DriverError as e: exc = e @@ -233,7 +233,7 @@ def work(tx): self._create_direct_driver() self._session = self._driver.session("r") with self.assertRaises(types.DriverError) as exc: - self._session.read_transaction(work) + self._session.execute_read(work) self.assertEqual(exc.exception.code, "Neo.ClientError.MadeUp.Code") def _test_failed_tx_run(self, rollback): diff --git a/tests/stub/types/test_temporal_types.py b/tests/stub/types/test_temporal_types.py index 6ca121655..013b210d1 100644 --- a/tests/stub/types/test_temporal_types.py +++ b/tests/stub/types/test_temporal_types.py @@ -86,7 +86,7 @@ def work(tx): self._create_direct_driver() self._session = self._driver.session("w") with self.assertRaises(types.DriverError): - self._session.read_transaction(work) + self._session.execute_read(work) self._server.done() # TODO: Remove once all drivers roll back failed managed transactions if get_driver_name() not in ["go"]: @@ -115,7 +115,7 @@ def work(tx): self._start_server(script) self._create_direct_driver() self._session = self._driver.session("w") - self._session.read_transaction(work) + self._session.execute_read(work) class TestTemporalTypesV3x0(_TestTemporalTypes):