@@ -113,7 +113,7 @@ def test_rollback_tx_on_session_close_finished_result(self):
113113 self ._session = None
114114 self ._server1 .done ()
115115
116- def _eager_tx_run (self , script , routing = False ):
116+ def _eager_tx_func_run (self , script , routing = False ):
117117 if routing :
118118 self ._create_routing_driver ()
119119 self ._router .start (
@@ -145,9 +145,10 @@ def work(tx):
145145 return exc , tx_func_count
146146
147147 @driver_feature (types .Feature .OPT_EAGER_TX_BEGIN )
148- def test_eager_begin_on_tx_run_with_disconnect_on_begin (self ):
149- exc , tx_func_count = self ._eager_tx_run ("tx_disconnect_on_begin.script" ,
150- routing = True )
148+ def test_eager_begin_on_tx_func_run_with_disconnect_on_begin (self ):
149+ exc , tx_func_count = self ._eager_tx_func_run (
150+ "tx_disconnect_on_begin.script" , routing = True
151+ )
151152 # Driver should retry tx on disconnect after BEGIN and call the tx func
152153 # exactly once (after the disconnect). The disconnect should make the
153154 # driver fetch a new routing table which will point to server2 the
@@ -160,11 +161,36 @@ def test_eager_begin_on_tx_run_with_disconnect_on_begin(self):
160161 self ._server2 .done ()
161162
162163 @driver_feature (types .Feature .OPT_EAGER_TX_BEGIN )
163- def test_eager_begin_on_tx_run_with_error_on_begin (self ):
164- exc , tx_func_count = self ._eager_tx_run ("tx_error_on_begin.script" ,
165- routing = False )
164+ def test_eager_begin_on_tx_func_run_with_error_on_begin (self ):
165+ exc , tx_func_count = self ._eager_tx_func_run ("tx_error_on_begin.script" ,
166+ routing = False )
166167 # Driver should raise error on non-transient error after BEGIN, and
167168 # never call the tx func.
168169 self .assertEqual ("Neo.ClientError.MadeUp.Code" , exc .code )
169170 self .assertEqual (tx_func_count , 0 )
170171 self ._server1 .done ()
172+
173+ def _eager_tx_run (self , script ):
174+ self ._create_direct_driver ()
175+ self ._server1 .start (path = self .script_path (script ))
176+
177+ self ._session = self ._driver .session ("w" )
178+ with self .assertRaises (types .DriverError ) as exc :
179+ self ._session .beginTransaction ()
180+
181+ self ._session .close ()
182+ self ._session = None
183+
184+ return exc .exception
185+
186+ @driver_feature (types .Feature .OPT_EAGER_TX_BEGIN )
187+ def test_eager_begin_on_tx_run_with_disconnect_on_begin (self ):
188+ exc = self ._eager_tx_run ("tx_disconnect_on_begin.script" )
189+ if get_driver_name () in ["python" ]:
190+ self .assertEqual ("<class 'neo4j.exceptions.ServiceUnavailable'>" ,
191+ exc .errorType )
192+
193+ @driver_feature (types .Feature .OPT_EAGER_TX_BEGIN )
194+ def test_eager_begin_on_tx_run_with_error_on_begin (self ):
195+ exc = self ._eager_tx_run ("tx_error_on_begin.script" )
196+ self .assertEqual ("Neo.ClientError.MadeUp.Code" , exc .code )
0 commit comments