Skip to content

Commit 98825c9

Browse files
authored
Merge pull request #636 from robsdedude/drop-deprecated-serverinfo-version_info
Drop deprecated `ResultSummary.server.version_info`
2 parents 0f53077 + 56b9712 commit 98825c9

File tree

5 files changed

+12
-50
lines changed

5 files changed

+12
-50
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
`neo4j.work`. They should've been imported from `neo4j` all along.
99
- Experimental pipelines feature has been removed.
1010
- Experimental async driver has been added.
11+
- `ResultSummary.server.version_info` has been removed.
12+
Use `ResultSummary.server.agent`, `ResultSummary.server.protocol_version`,
13+
or call the `dbms.components` procedure instead.
1114

1215
## Version 4.4
1316

neo4j/api.py

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -242,46 +242,6 @@ def connection_id(self):
242242
"""
243243
return self._metadata.get("connection_id")
244244

245-
# TODO in 5.0: remove this method
246-
@deprecated("The version_info method is deprecated, please use "
247-
"ServerInfo.agent, ServerInfo.protocol_version, or "
248-
"call the dbms.components procedure instead")
249-
def version_info(self):
250-
"""Return the server version if available.
251-
252-
:return: Server Version or None
253-
:rtype: tuple
254-
255-
.. deprecated:: 4.3
256-
`version_info` will be removed in version 5.0. Use
257-
:meth:`~ServerInfo.agent`, :meth:`~ServerInfo.protocol_version`,
258-
or call the `dbms.components` procedure instead.
259-
"""
260-
if not self.agent:
261-
return None
262-
# Note: Confirm that the server agent string begins with "Neo4j/" and fail gracefully if not.
263-
# This is intended to help prevent drivers working for non-genuine Neo4j instances.
264-
265-
prefix, _, value = self.agent.partition("/")
266-
try:
267-
assert prefix in ["Neo4j"]
268-
except AssertionError:
269-
raise DriverError("Server name does not start with Neo4j/")
270-
271-
try:
272-
if self.protocol_version >= (4, 0):
273-
return self.protocol_version
274-
except TypeError:
275-
pass
276-
277-
value = value.replace("-", ".").split(".")
278-
for i, v in enumerate(value):
279-
try:
280-
value[i] = int(v)
281-
except ValueError:
282-
pass
283-
return tuple(value)
284-
285245
def update(self, metadata):
286246
""" Update server information with extra metadata. This is
287247
typically drawn from the metadata received after successful

tests/unit/async_/work/test_result.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,6 @@ async def test_consume(records, consume_one, summary_meta):
370370
assert summary.database is None
371371
server_info = summary.server
372372
assert isinstance(server_info, ServerInfo)
373-
assert server_info.version_info() == Version(4, 3)
374373
assert server_info.protocol_version == Version(4, 3)
375374
assert isinstance(summary.counters, SummaryCounters)
376375

tests/unit/common/test_api.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -299,26 +299,27 @@ def test_serverinfo_initialization():
299299

300300

301301
@pytest.mark.parametrize(
302-
"test_input, expected_agent, expected_version_info",
302+
"test_input, expected_agent",
303303
[
304-
({"server": "Neo4j/3.0.0"}, "Neo4j/3.0.0", (3, 0, 0)),
305-
({"server": "Neo4j/3.X.Y"}, "Neo4j/3.X.Y", (3, "X", "Y")),
306-
({"server": "Neo4j/4.3.1"}, "Neo4j/4.3.1", (4, 3, 1)),
304+
({"server": "Neo4j/3.0.0"}, "Neo4j/3.0.0"),
305+
({"server": "Neo4j/3.X.Y"}, "Neo4j/3.X.Y"),
306+
({"server": "Neo4j/4.3.1"}, "Neo4j/4.3.1"),
307307
]
308308
)
309-
def test_serverinfo_with_metadata(test_input, expected_agent, expected_version_info):
309+
@pytest.mark.parametrize("protocol_version", ((3, 0), (4, 3), (42, 1337)))
310+
def test_serverinfo_with_metadata(test_input, expected_agent,
311+
protocol_version):
310312
from neo4j.addressing import Address
311313

312314
address = Address(("bolt://localhost", 7687))
313-
version = neo4j.api.Version(3, 0)
315+
version = neo4j.api.Version(*protocol_version)
314316

315317
server_info = neo4j.api.ServerInfo(address, version)
316318

317319
server_info.update(test_input)
318320

319321
assert server_info.agent == expected_agent
320-
with pytest.warns(DeprecationWarning):
321-
assert server_info.version_info() == expected_version_info
322+
assert server_info.protocol_version == version
322323

323324

324325
@pytest.mark.parametrize(

tests/unit/sync/work/test_result.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,6 @@ def test_consume(records, consume_one, summary_meta):
370370
assert summary.database is None
371371
server_info = summary.server
372372
assert isinstance(server_info, ServerInfo)
373-
assert server_info.version_info() == Version(4, 3)
374373
assert server_info.protocol_version == Version(4, 3)
375374
assert isinstance(summary.counters, SummaryCounters)
376375

0 commit comments

Comments
 (0)