From 56b9712f3526a0f3bcc68376d8418ab865c10e39 Mon Sep 17 00:00:00 2001 From: Rouven Bauer Date: Tue, 4 Jan 2022 14:28:44 +0100 Subject: [PATCH] Drop deprecated `ResultSummary.server.version_info` --- CHANGELOG.md | 3 ++ neo4j/api.py | 40 --------------------------- tests/unit/async_/work/test_result.py | 1 - tests/unit/common/test_api.py | 17 ++++++------ tests/unit/sync/work/test_result.py | 1 - 5 files changed, 12 insertions(+), 50 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f6e2000..55019866 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/neo4j/api.py b/neo4j/api.py index 36c05cbb..9d4ff34e 100644 --- a/neo4j/api.py +++ b/neo4j/api.py @@ -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 diff --git a/tests/unit/async_/work/test_result.py b/tests/unit/async_/work/test_result.py index d73acaab..4b8f6d00 100644 --- a/tests/unit/async_/work/test_result.py +++ b/tests/unit/async_/work/test_result.py @@ -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) diff --git a/tests/unit/common/test_api.py b/tests/unit/common/test_api.py index 6e3caa07..78bf7639 100644 --- a/tests/unit/common/test_api.py +++ b/tests/unit/common/test_api.py @@ -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( diff --git a/tests/unit/sync/work/test_result.py b/tests/unit/sync/work/test_result.py index 863df838..a3b00345 100644 --- a/tests/unit/sync/work/test_result.py +++ b/tests/unit/sync/work/test_result.py @@ -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)