Skip to content

Drop deprecated ResultSummary.server.version_info #636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
`neo4j.work`. They should've been imported from `neo4j` all along.
- Experimental pipelines feature has been removed.
- Experimental async driver has been added.
- `ResultSummary.server.version_info` has been removed.
Use `ResultSummary.server.agent`, `ResultSummary.server.protocol_version`,
or call the `dbms.components` procedure instead.

## Version 4.4

Expand Down
40 changes: 0 additions & 40 deletions neo4j/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,46 +242,6 @@ def connection_id(self):
"""
return self._metadata.get("connection_id")

# TODO in 5.0: remove this method
@deprecated("The version_info method is deprecated, please use "
"ServerInfo.agent, ServerInfo.protocol_version, or "
"call the dbms.components procedure instead")
def version_info(self):
"""Return the server version if available.

:return: Server Version or None
:rtype: tuple

.. deprecated:: 4.3
`version_info` will be removed in version 5.0. Use
:meth:`~ServerInfo.agent`, :meth:`~ServerInfo.protocol_version`,
or call the `dbms.components` procedure instead.
"""
if not self.agent:
return None
# Note: Confirm that the server agent string begins with "Neo4j/" and fail gracefully if not.
# This is intended to help prevent drivers working for non-genuine Neo4j instances.

prefix, _, value = self.agent.partition("/")
try:
assert prefix in ["Neo4j"]
except AssertionError:
raise DriverError("Server name does not start with Neo4j/")

try:
if self.protocol_version >= (4, 0):
return self.protocol_version
except TypeError:
pass

value = value.replace("-", ".").split(".")
for i, v in enumerate(value):
try:
value[i] = int(v)
except ValueError:
pass
return tuple(value)

def update(self, metadata):
""" Update server information with extra metadata. This is
typically drawn from the metadata received after successful
Expand Down
1 change: 0 additions & 1 deletion tests/unit/async_/work/test_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ async def test_consume(records, consume_one, summary_meta):
assert summary.database is None
server_info = summary.server
assert isinstance(server_info, ServerInfo)
assert server_info.version_info() == Version(4, 3)
assert server_info.protocol_version == Version(4, 3)
assert isinstance(summary.counters, SummaryCounters)

Expand Down
17 changes: 9 additions & 8 deletions tests/unit/common/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,26 +299,27 @@ def test_serverinfo_initialization():


@pytest.mark.parametrize(
"test_input, expected_agent, expected_version_info",
"test_input, expected_agent",
[
({"server": "Neo4j/3.0.0"}, "Neo4j/3.0.0", (3, 0, 0)),
({"server": "Neo4j/3.X.Y"}, "Neo4j/3.X.Y", (3, "X", "Y")),
({"server": "Neo4j/4.3.1"}, "Neo4j/4.3.1", (4, 3, 1)),
({"server": "Neo4j/3.0.0"}, "Neo4j/3.0.0"),
({"server": "Neo4j/3.X.Y"}, "Neo4j/3.X.Y"),
({"server": "Neo4j/4.3.1"}, "Neo4j/4.3.1"),
]
)
def test_serverinfo_with_metadata(test_input, expected_agent, expected_version_info):
@pytest.mark.parametrize("protocol_version", ((3, 0), (4, 3), (42, 1337)))
def test_serverinfo_with_metadata(test_input, expected_agent,
protocol_version):
from neo4j.addressing import Address

address = Address(("bolt://localhost", 7687))
version = neo4j.api.Version(3, 0)
version = neo4j.api.Version(*protocol_version)

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

server_info.update(test_input)

assert server_info.agent == expected_agent
with pytest.warns(DeprecationWarning):
assert server_info.version_info() == expected_version_info
assert server_info.protocol_version == version


@pytest.mark.parametrize(
Expand Down
1 change: 0 additions & 1 deletion tests/unit/sync/work/test_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ def test_consume(records, consume_one, summary_meta):
assert summary.database is None
server_info = summary.server
assert isinstance(server_info, ServerInfo)
assert server_info.version_info() == Version(4, 3)
assert server_info.protocol_version == Version(4, 3)
assert isinstance(summary.counters, SummaryCounters)

Expand Down