@@ -60,198 +60,6 @@ def test_encrypted_set_to_false_by_default(bolt_driver):
6060 assert bolt_driver .encrypted is False
6161
6262
63- def test_bolt_driver_fetch_size_config_case_on_close_result_consume (bolt_uri , auth ):
64- # python -m pytest tests/integration/test_bolt_driver.py -s -v -k test_bolt_driver_fetch_size_config_case_on_close_result_consume
65- try :
66- with GraphDatabase .driver (bolt_uri , auth = auth , user_agent = "test" ) as driver :
67- assert isinstance (driver , BoltDriver )
68- with driver .session (fetch_size = 2 , default_access_mode = READ_ACCESS ) as session :
69- result = session .run ("UNWIND [1,2,3,4] AS x RETURN x" )
70- # Check the expected result with logging manually
71- except ServiceUnavailable as error :
72- if isinstance (error .__cause__ , BoltHandshakeError ):
73- pytest .skip (error .args [0 ])
74-
75-
76- def test_bolt_driver_fetch_size_config_case_normal (bolt_uri , auth ):
77- # python -m pytest tests/integration/test_bolt_driver.py -s -v -k test_bolt_driver_fetch_size_config_case_normal
78- try :
79- with GraphDatabase .driver (bolt_uri , auth = auth , user_agent = "test" ) as driver :
80- assert isinstance (driver , BoltDriver )
81- with driver .session (fetch_size = 2 , default_access_mode = READ_ACCESS ) as session :
82- expected = []
83- result = session .run ("UNWIND [1,2,3,4] AS x RETURN x" )
84- for record in result :
85- expected .append (record ["x" ])
86-
87- assert expected == [1 , 2 , 3 , 4 ]
88- except ServiceUnavailable as error :
89- if isinstance (error .__cause__ , BoltHandshakeError ):
90- pytest .skip (error .args [0 ])
91-
92-
93- def test_bolt_driver_fetch_size_config_run_consume_run (bolt_uri , auth ):
94- # python -m pytest tests/integration/test_bolt_driver.py -s -v -k test_bolt_driver_fetch_size_config_run_consume_run
95- try :
96- with GraphDatabase .driver (bolt_uri , auth = auth , user_agent = "test" ) as driver :
97- assert isinstance (driver , BoltDriver )
98- with driver .session (fetch_size = 2 , default_access_mode = READ_ACCESS ) as session :
99- expected = []
100- result1 = session .run ("UNWIND [1,2,3,4] AS x RETURN x" )
101- result1 .consume ()
102- result2 = session .run ("UNWIND [5,6,7,8] AS x RETURN x" )
103-
104- for record in result2 :
105- expected .append (record ["x" ])
106-
107- result_summary = result2 .consume ()
108- assert isinstance (result_summary , ResultSummary )
109-
110- assert expected == [5 , 6 , 7 , 8 ]
111- except ServiceUnavailable as error :
112- if isinstance (error .__cause__ , BoltHandshakeError ):
113- pytest .skip (error .args [0 ])
114-
115-
116- def test_bolt_driver_fetch_size_config_run_run (bolt_uri , auth ):
117- # python -m pytest tests/integration/test_bolt_driver.py -s -v -k test_bolt_driver_fetch_size_config_run_run
118- try :
119- with GraphDatabase .driver (bolt_uri , auth = auth , user_agent = "test" ) as driver :
120- assert isinstance (driver , BoltDriver )
121- with driver .session (fetch_size = 2 , default_access_mode = READ_ACCESS ) as session :
122- expected = []
123- result1 = session .run ("UNWIND [1,2,3,4] AS x RETURN x" )
124- result2 = session .run ("UNWIND [5,6,7,8] AS x RETURN x" )
125-
126- for record in result2 :
127- expected .append (record ["x" ])
128-
129- result_summary = result2 .consume ()
130- assert isinstance (result_summary , ResultSummary )
131-
132- assert expected == [5 , 6 , 7 , 8 ]
133- except ServiceUnavailable as error :
134- if isinstance (error .__cause__ , BoltHandshakeError ):
135- pytest .skip (error .args [0 ])
136-
137-
138- def test_bolt_driver_read_transaction_fetch_size_config_normal_case (bolt_uri , auth ):
139- # python -m pytest tests/integration/test_bolt_driver.py -s -v -k test_bolt_driver_read_transaction_fetch_size_config_normal_case
140- @unit_of_work (timeout = 3 , metadata = {"foo" : "bar" })
141- def unwind (transaction ):
142- assert isinstance (transaction , Transaction )
143- values = []
144- result = transaction .run ("UNWIND [1,2,3,4] AS x RETURN x" )
145- assert isinstance (result , Result )
146- for record in result :
147- values .append (record ["x" ])
148- return values
149-
150- try :
151- with GraphDatabase .driver (bolt_uri , auth = auth , user_agent = "test" ) as driver :
152- assert isinstance (driver , BoltDriver )
153- with driver .session (fetch_size = 2 , default_access_mode = READ_ACCESS ) as session :
154- expected = session .read_transaction (unwind )
155-
156- assert expected == [1 , 2 , 3 , 4 ]
157- except ServiceUnavailable as error :
158- if isinstance (error .__cause__ , BoltHandshakeError ):
159- pytest .skip (error .args [0 ])
160-
161-
162- def test_bolt_driver_multiple_results_case_1 (bolt_uri , auth ):
163- # python -m pytest tests/integration/test_bolt_driver.py -s -v -k test_bolt_driver_multiple_results_case_1
164- try :
165- with GraphDatabase .driver (bolt_uri , auth = auth , user_agent = "test" ) as driver :
166- assert isinstance (driver , BoltDriver )
167- with driver .session (fetch_size = 2 , default_access_mode = READ_ACCESS ) as session :
168- transaction = session .begin_transaction (timeout = 3 , metadata = {"foo" : "bar" })
169- result1 = transaction .run ("UNWIND [1,2,3,4] AS x RETURN x" )
170- values1 = []
171- for ix in result1 :
172- values1 .append (ix ["x" ])
173- transaction .commit ()
174- assert values1 == [1 , 2 , 3 , 4 ]
175-
176- except ServiceUnavailable as error :
177- if isinstance (error .__cause__ , BoltHandshakeError ):
178- pytest .skip (error .args [0 ])
179-
180-
181- def test_bolt_driver_multiple_results_case_2 (bolt_uri , auth ):
182- # python -m pytest tests/integration/test_bolt_driver.py -s -v -k test_bolt_driver_multiple_results_case_2
183- try :
184- with GraphDatabase .driver (bolt_uri , auth = auth , user_agent = "test" ) as driver :
185- assert isinstance (driver , BoltDriver )
186- with driver .session (fetch_size = 2 , default_access_mode = READ_ACCESS ) as session :
187- transaction = session .begin_transaction (timeout = 3 , metadata = {"foo" : "bar" })
188- result1 = transaction .run ("UNWIND [1,2,3,4] AS x RETURN x" )
189- result2 = transaction .run ("UNWIND [5,6,7,8] AS x RETURN x" )
190- values1 = []
191- values2 = []
192- for ix in result2 :
193- values2 .append (ix ["x" ])
194- for ix in result1 :
195- values1 .append (ix ["x" ])
196- transaction .commit ()
197- assert values2 == [5 , 6 , 7 , 8 ]
198- assert values1 == [1 , 2 , 3 , 4 ]
199-
200- except ServiceUnavailable as error :
201- if isinstance (error .__cause__ , BoltHandshakeError ):
202- pytest .skip (error .args [0 ])
203-
204-
205- def test_bolt_driver_multiple_results_case_3 (bolt_uri , auth ):
206- # python -m pytest tests/integration/test_bolt_driver.py -s -v -k test_bolt_driver_multiple_results_case_3
207- try :
208- with GraphDatabase .driver (bolt_uri , auth = auth , user_agent = "test" ) as driver :
209- assert isinstance (driver , BoltDriver )
210- with driver .session (fetch_size = 2 , default_access_mode = READ_ACCESS ) as session :
211- transaction = session .begin_transaction (timeout = 3 , metadata = {"foo" : "bar" })
212- values1 = []
213- values2 = []
214- result1 = transaction .run ("UNWIND [1,2,3,4] AS x RETURN x" )
215- result1_iter = iter (result1 )
216- values1 .append (next (result1_iter )["x" ])
217- result2 = transaction .run ("UNWIND [5,6,7,8] AS x RETURN x" )
218- for ix in result2 :
219- values2 .append (ix ["x" ])
220- transaction .commit () # Should discard the rest of records in result1 and result2 -> then set mode discard.
221- assert values2 == [5 , 6 , 7 , 8 ]
222- assert result2 ._closed is True
223- assert values1 == [1 , ]
224-
225- try :
226- values1 .append (next (result1_iter )["x" ])
227- except StopIteration as e :
228- # Bolt 4.0
229- assert values1 == [1 , ]
230- assert result1 ._closed is True
231- else :
232- # Bolt 3 only have PULL ALL and no qid so it will behave like autocommit r1=session.run rs2=session.run
233- values1 .append (next (result1_iter )["x" ])
234- assert values1 == [1 , 2 , 3 ]
235- assert result1 ._closed is False
236-
237- assert result1 ._closed is True
238-
239- except ServiceUnavailable as error :
240- if isinstance (error .__cause__ , BoltHandshakeError ):
241- pytest .skip (error .args [0 ])
242-
243-
244- def test_bolt_driver_case_pull_no_records (driver ):
245- # python -m pytest tests/integration/test_bolt_driver.py -s -v -k test_bolt_driver_case_pull_no_records
246- try :
247- with driver .session (default_access_mode = WRITE_ACCESS ) as session :
248- with session .begin_transaction () as tx :
249- result = tx .run ("CREATE (a:Thing {uuid:$uuid})" , uuid = 123 )
250- except ServiceUnavailable as error :
251- if isinstance (error .__cause__ , BoltHandshakeError ):
252- pytest .skip (error .args [0 ])
253-
254-
25563@fixture
25664def server_info (driver ):
25765 """ Simple fixture to provide quick and easy access to a
@@ -262,18 +70,8 @@ def server_info(driver):
26270 yield summary .server
26371
26472
265- def test_server_address (server_info ):
266- assert server_info .address == ("127.0.0.1" , 7687 )
267-
268-
269- def test_server_protocol_version (server_info ):
270- assert server_info .protocol_version >= (3 , 0 )
271-
272-
273- def test_server_agent (server_info ):
274- assert server_info .agent .startswith ("Neo4j/" )
275-
276-
73+ # TODO: this test will stay asy python is currently the only driver exposing the
74+ # connection id. So this might change in the future.
27775def test_server_connection_id (server_info ):
27876 cid = server_info .connection_id
27977 assert cid .startswith ("bolt-" ) and cid [5 :].isdigit ()
0 commit comments