From 930a7aa1a4bf9b11641a4ddc523e1886fc04e4b4 Mon Sep 17 00:00:00 2001 From: Prychantovskyi Date: Mon, 17 Oct 2022 11:09:19 +0100 Subject: [PATCH 01/20] One more try of pushing changes on 4.4 version of driver for Python 3.10 --- CHANGELOG.md | 5 ++ README.rst | 1 + TESTING.md | 2 +- docs/source/index.rst | 1 + neo4j/conf.py | 16 ++-- setup.py | 1 + tests/unit/test_conf.py | 177 +++++++++++++++++++++++++--------------- tox-unit.ini | 1 + tox.ini | 1 + 9 files changed, 132 insertions(+), 73 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ac71da9..d1294bc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Neo4j Driver Change Log +## Version 4.4.9 + +- Python 3.10 support added (driver version 4.4.9) + + ## Version 4.4 - Python 3.5 support has been dropped. diff --git a/README.rst b/README.rst index d905dc7c..d5e28881 100644 --- a/README.rst +++ b/README.rst @@ -6,6 +6,7 @@ This repository contains the official Neo4j driver for Python. Each driver release (from 4.0 upwards) is built specifically to work with a corresponding Neo4j release, i.e. that with the same `major.minor` version number. These drivers will also be compatible with the previous Neo4j release, although new server features will not be available. ++ Python 3.10 supported. + Python 3.9 supported. + Python 3.8 supported. + Python 3.7 supported. diff --git a/TESTING.md b/TESTING.md index 88d99878..d15dc3fb 100644 --- a/TESTING.md +++ b/TESTING.md @@ -1,7 +1,7 @@ # Neo4j Driver Testing To run driver tests, [Tox](https://tox.readthedocs.io) is required as well as at least one version of Python. -The versions of Python supported by this driver are CPython 3.6, 3.7, 3.8, and 3.9. +The versions of Python supported by this driver are CPython 3.6, 3.7, 3.8, 3.9 and 3.10. ## Unit Tests & Stub Tests diff --git a/docs/source/index.rst b/docs/source/index.rst index b0b973b7..42cf1105 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -12,6 +12,7 @@ Neo4j versions supported: Python versions supported: +* Python 3.10 (added in driver version 4.4.9) * Python 3.9 * Python 3.8 * Python 3.7 diff --git a/neo4j/conf.py b/neo4j/conf.py index cb18ee26..8a9d5f12 100644 --- a/neo4j/conf.py +++ b/neo4j/conf.py @@ -19,6 +19,7 @@ # limitations under the License. +import sys from abc import ABCMeta from collections.abc import Mapping import warnings @@ -83,7 +84,9 @@ def __new__(mcs, name, bases, attributes): for k, v in attributes.items(): if isinstance(v, DeprecatedAlias): deprecated_aliases[k] = v.new - elif not k.startswith("_") and not callable(v): + elif not (k.startswith("_") + or callable(v) + or isinstance(v, (staticmethod, classmethod))): fields.append(k) if isinstance(v, DeprecatedOption): deprecated_options[k] = v.value @@ -286,8 +289,11 @@ def get_ssl_context(self): # For recommended security options see # https://docs.python.org/3.6/library/ssl.html#protocol-versions - ssl_context.options |= ssl.OP_NO_TLSv1 # Python 3.2 - ssl_context.options |= ssl.OP_NO_TLSv1_1 # Python 3.4 + if sys.version_info >= (3, 7): + ssl_context.minimum_version = ssl.TLSVersion.TLSv1_2 # Python 3.10 + else: + ssl_context.options |= ssl.OP_NO_TLSv1 # Python 3.2 + ssl_context.options |= ssl.OP_NO_TLSv1_1 # Python 3.4 if self.trust == TRUST_ALL_CERTIFICATES: @@ -357,11 +363,9 @@ class SessionConfig(WorkspaceConfig): class TransactionConfig(Config): """ Transaction configuration. This is internal for now. - neo4j.session.begin_transaction neo4j.Query neo4j.unit_of_work - are both using the same settings. """ #: Metadata @@ -383,4 +387,4 @@ class RoutingConfig(Config): # max_routing_failures = 1 #: Retry Timeout Delay - # retry_timeout_delay = 5.0 # seconds + # retry_timeout_delay = 5.0 # seconds \ No newline at end of file diff --git a/setup.py b/setup.py index 349b6391..45358ce1 100644 --- a/setup.py +++ b/setup.py @@ -37,6 +37,7 @@ "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", ] entry_points = { "console_scripts": [ diff --git a/tests/unit/test_conf.py b/tests/unit/test_conf.py index 561a1330..2cbdf470 100644 --- a/tests/unit/test_conf.py +++ b/tests/unit/test_conf.py @@ -22,6 +22,7 @@ from contextlib import contextmanager import warnings +import ssl import pytest from neo4j.exceptions import ( @@ -35,6 +36,7 @@ ) from neo4j.api import ( TRUST_SYSTEM_CA_SIGNED_CERTIFICATES, + TRUST_ALL_CERTIFICATES, WRITE_ACCESS, READ_ACCESS, ) @@ -75,26 +77,11 @@ config_function_names = ["consume_chain", "consume"] -@contextmanager -def _pool_config_deprecations(): - with pytest.warns(DeprecationWarning, - match="update_routing_table_timeout") as warnings: - yield warnings - - -@contextmanager -def _session_config_deprecations(): - with pytest.warns(DeprecationWarning, - match="session_connection_timeout") as warnings: - yield warnings - - def test_pool_config_consume(): test_config = dict(test_pool_config) - with _pool_config_deprecations(): - consumed_pool_config = PoolConfig.consume(test_config) + consumed_pool_config = PoolConfig.consume(test_config) assert isinstance(consumed_pool_config, PoolConfig) @@ -103,12 +90,10 @@ def test_pool_config_consume(): for key in test_pool_config.keys(): assert consumed_pool_config[key] == test_pool_config[key] - for key in consumed_pool_config.keys(): - if key not in config_function_names: - assert test_pool_config[key] == consumed_pool_config[key] + for key, val in consumed_pool_config.items(): + assert test_pool_config[key] == val - assert (len(consumed_pool_config) - len(config_function_names) - == len(test_pool_config)) + assert len(consumed_pool_config) == len(test_pool_config) def test_pool_config_consume_default_values(): @@ -133,11 +118,7 @@ def test_pool_config_consume_key_not_valid(): test_config["not_valid_key"] = "test" with pytest.raises(ConfigurationError) as error: - # might or might not warn DeprecationWarning, but we're only - # interested in the error - with warnings.catch_warnings(): - warnings.filterwarnings("ignore", category=DeprecationWarning) - _ = PoolConfig.consume(test_config) + consumed_pool_config = PoolConfig.consume(test_config) error.match("Unexpected config keys: not_valid_key") @@ -146,8 +127,7 @@ def test_pool_config_set_value(): test_config = dict(test_pool_config) - with _pool_config_deprecations(): - consumed_pool_config = PoolConfig.consume(test_config) + consumed_pool_config = PoolConfig.consume(test_config) assert consumed_pool_config.get("encrypted") is False assert consumed_pool_config["encrypted"] is False @@ -165,22 +145,15 @@ def test_pool_config_set_value(): def test_pool_config_consume_and_then_consume_again(): test_config = dict(test_pool_config) - with _pool_config_deprecations(): - consumed_pool_config = PoolConfig.consume(test_config) + consumed_pool_config = PoolConfig.consume(test_config) assert consumed_pool_config.encrypted is False consumed_pool_config.encrypted = "test" with pytest.raises(AttributeError): - _ = PoolConfig.consume(consumed_pool_config) + consumed_pool_config = PoolConfig.consume(consumed_pool_config) - with _pool_config_deprecations(): - consumed_pool_config = PoolConfig.consume( - dict(consumed_pool_config.items()) - ) - with _pool_config_deprecations(): - consumed_pool_config = PoolConfig.consume( - dict(consumed_pool_config.items()) - ) + consumed_pool_config = PoolConfig.consume(dict(consumed_pool_config.items())) + consumed_pool_config = PoolConfig.consume(dict(consumed_pool_config.items())) assert consumed_pool_config.encrypted == "test" @@ -188,14 +161,12 @@ def test_pool_config_consume_and_then_consume_again(): def test_config_consume_chain(): test_config = {} + test_config.update(test_pool_config) + test_config.update(test_session_config) - with warnings.catch_warnings(): - warnings.filterwarnings("ignore", category=DeprecationWarning) - consumed_pool_config, consumed_session_config = Config.consume_chain( - test_config, PoolConfig, SessionConfig - ) + consumed_pool_config, consumed_session_config = Config.consume_chain(test_config, PoolConfig, SessionConfig) assert isinstance(consumed_pool_config, PoolConfig) assert isinstance(consumed_session_config, SessionConfig) @@ -206,14 +177,11 @@ def test_config_consume_chain(): assert consumed_pool_config[key] == val for key, val in consumed_pool_config.items(): - if key not in config_function_names: - assert test_pool_config[key] == val + assert test_pool_config[key] == val - assert (len(consumed_pool_config) - len(config_function_names) - == len(test_pool_config)) + assert len(consumed_pool_config) == len(test_pool_config) - assert (len(consumed_session_config) - len(config_function_names) - == len(test_session_config)) + assert len(consumed_session_config) == len(test_session_config) def test_init_session_config_merge(): @@ -263,19 +231,96 @@ def test_init_session_config_with_not_valid_key(): assert session_config.connection_acquisition_timeout == 333 -def test_pool_config_deprecated_update_routing_table_timeout(): - with _pool_config_deprecations(): - _ = PoolConfig.consume({"update_routing_table_timeout": 1}) - - with warnings.catch_warnings(): - warnings.simplefilter("error") - _ = PoolConfig.consume({}) - - -def test_session_config_deprecated_session_connection_timeout(): - with _session_config_deprecations(): - _ = SessionConfig.consume({"session_connection_timeout": 1}) - - with warnings.catch_warnings(): - warnings.simplefilter("error") - _ = SessionConfig.consume({}) +@pytest.mark.parametrize("config", ( + {}, + {"encrypted": False}, + {"trust": TRUST_SYSTEM_CA_SIGNED_CERTIFICATES}, + {"trust": TRUST_ALL_CERTIFICATES}, +)) +def test_no_ssl_mock(config, mocker): + ssl_context_mock = mocker.patch("ssl.SSLContext", autospec=True) + pool_config = PoolConfig.consume(config) + assert pool_config.encrypted is False + assert pool_config.get_ssl_context() is None + ssl_context_mock.assert_not_called() + + +@pytest.mark.parametrize("config", ( + {"encrypted": True}, + {"encrypted": True, "trust": TRUST_SYSTEM_CA_SIGNED_CERTIFICATES}, +)) +def test_trust_system_cas_mock(config, mocker): + ssl_context_mock = mocker.patch("ssl.SSLContext", autospec=True) + pool_config = PoolConfig.consume(config) + assert pool_config.encrypted is True + ssl_context = pool_config.get_ssl_context() + _assert_mock_tls_1_2(ssl_context_mock) + assert ssl_context.minimum_version == ssl.TLSVersion.TLSv1_2 + ssl_context_mock.return_value.load_default_certs.assert_called_once_with() + ssl_context_mock.return_value.load_verify_locations.assert_not_called() + assert ssl_context.check_hostname + assert ssl_context.verify_mode + + +@pytest.mark.parametrize("config", ( + {"encrypted": True, "trust": TRUST_ALL_CERTIFICATES}, +)) +def test_trust_all_mock(config, mocker): + ssl_context_mock = mocker.patch("ssl.SSLContext", autospec=True) + pool_config = PoolConfig.consume(config) + assert pool_config.encrypted is True + ssl_context = pool_config.get_ssl_context() + _assert_mock_tls_1_2(ssl_context_mock) + assert ssl_context.minimum_version == ssl.TLSVersion.TLSv1_2 + ssl_context_mock.return_value.load_verify_locations.assert_not_called() + assert ssl_context.check_hostname is False + assert ssl_context.verify_mode is ssl.CERT_NONE + + +def _assert_mock_tls_1_2(mock): + mock.assert_called_once_with(ssl.PROTOCOL_TLS_CLIENT) + assert mock.return_value.minimum_version == ssl.TLSVersion.TLSv1_2 + + +@pytest.mark.parametrize("config", ( + {}, + {"encrypted": False}, + {"trust": TRUST_SYSTEM_CA_SIGNED_CERTIFICATES}, + {"trust": TRUST_ALL_CERTIFICATES}, +)) +def test_no_ssl(config): + pool_config = PoolConfig.consume(config) + assert pool_config.encrypted is False + assert pool_config.get_ssl_context() is None + + +@pytest.mark.parametrize("config", ( + {"encrypted": True}, + {"encrypted": True, "trust": TRUST_SYSTEM_CA_SIGNED_CERTIFICATES}, +)) +def test_trust_system_cas(config): + pool_config = PoolConfig.consume(config) + assert pool_config.encrypted is True + ssl_context = pool_config.get_ssl_context() + assert isinstance(ssl_context, ssl.SSLContext) + _assert_context_tls_1_2(ssl_context) + assert ssl_context.check_hostname is True + assert ssl_context.verify_mode == ssl.CERT_REQUIRED + + +@pytest.mark.parametrize("config", ( + {"encrypted": True, "trust": TRUST_ALL_CERTIFICATES}, +)) +def test_trust_all(config): + pool_config = PoolConfig.consume(config) + assert pool_config.encrypted is True + ssl_context = pool_config.get_ssl_context() + assert isinstance(ssl_context, ssl.SSLContext) + _assert_context_tls_1_2(ssl_context) + assert ssl_context.check_hostname is False + assert ssl_context.verify_mode is ssl.CERT_NONE + + +def _assert_context_tls_1_2(ctx): + assert ctx.protocol == ssl.PROTOCOL_TLS_CLIENT + assert ctx.minimum_version == ssl.TLSVersion.TLSv1_2 diff --git a/tox-unit.ini b/tox-unit.ini index 8d771723..d4d7664e 100644 --- a/tox-unit.ini +++ b/tox-unit.ini @@ -4,6 +4,7 @@ envlist = py37 py38 py39 + py310 [testenv] deps = diff --git a/tox.ini b/tox.ini index 17afb1b7..15413083 100644 --- a/tox.ini +++ b/tox.ini @@ -4,6 +4,7 @@ envlist = py37 py38 py39 + py310 [testenv] passenv = From 0bb561a1e568077db0b3a52e33f3a3382e932415 Mon Sep 17 00:00:00 2001 From: Prychantovskyi Date: Mon, 17 Oct 2022 16:46:18 +0100 Subject: [PATCH 02/20] Little polish of rework --- neo4j/conf.py | 5 +++-- tests/unit/test_conf.py | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/neo4j/conf.py b/neo4j/conf.py index 8a9d5f12..8e4ec6ae 100644 --- a/neo4j/conf.py +++ b/neo4j/conf.py @@ -89,7 +89,6 @@ def __new__(mcs, name, bases, attributes): or isinstance(v, (staticmethod, classmethod))): fields.append(k) if isinstance(v, DeprecatedOption): - deprecated_options[k] = v.value attributes[k] = v.value def keys(_): @@ -157,6 +156,8 @@ def __update(self, data): def set_attr(k, v): if k in self.keys(): if k in self._deprecated_options(): + print("tebya ebut ") + print(self._deprecated_options()) deprecation_warn("The '{}' config key is " "deprecated".format(k)) setattr(self, k, v) @@ -387,4 +388,4 @@ class RoutingConfig(Config): # max_routing_failures = 1 #: Retry Timeout Delay - # retry_timeout_delay = 5.0 # seconds \ No newline at end of file + # retry_timeout_delay = 5.0 # seconds diff --git a/tests/unit/test_conf.py b/tests/unit/test_conf.py index 2cbdf470..b658be62 100644 --- a/tests/unit/test_conf.py +++ b/tests/unit/test_conf.py @@ -23,6 +23,7 @@ import warnings import ssl +import sys import pytest from neo4j.exceptions import ( @@ -322,5 +323,6 @@ def test_trust_all(config): def _assert_context_tls_1_2(ctx): - assert ctx.protocol == ssl.PROTOCOL_TLS_CLIENT - assert ctx.minimum_version == ssl.TLSVersion.TLSv1_2 + if sys.version_info >= (3, 7): + assert ctx.protocol == ssl.PROTOCOL_TLS_CLIENT + assert ctx.minimum_version == ssl.TLSVersion.TLSv1_2 From ba5b1a683b40b289b5e180cb1af0396287136742 Mon Sep 17 00:00:00 2001 From: Prychantovskyi Date: Tue, 18 Oct 2022 10:50:09 +0100 Subject: [PATCH 03/20] Rework for Python 3.6 --- tests/requirements.txt | 2 +- tests/unit/test_conf.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/requirements.txt b/tests/requirements.txt index 56b4d66e..4f9b30c2 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -3,6 +3,6 @@ coverage pytest pytest-benchmark pytest-cov -pytest-mock +pytest-mock~=3.6.1 teamcity-messages pandas>=1.0.0 diff --git a/tests/unit/test_conf.py b/tests/unit/test_conf.py index b658be62..dbc13580 100644 --- a/tests/unit/test_conf.py +++ b/tests/unit/test_conf.py @@ -256,7 +256,6 @@ def test_trust_system_cas_mock(config, mocker): assert pool_config.encrypted is True ssl_context = pool_config.get_ssl_context() _assert_mock_tls_1_2(ssl_context_mock) - assert ssl_context.minimum_version == ssl.TLSVersion.TLSv1_2 ssl_context_mock.return_value.load_default_certs.assert_called_once_with() ssl_context_mock.return_value.load_verify_locations.assert_not_called() assert ssl_context.check_hostname @@ -272,7 +271,6 @@ def test_trust_all_mock(config, mocker): assert pool_config.encrypted is True ssl_context = pool_config.get_ssl_context() _assert_mock_tls_1_2(ssl_context_mock) - assert ssl_context.minimum_version == ssl.TLSVersion.TLSv1_2 ssl_context_mock.return_value.load_verify_locations.assert_not_called() assert ssl_context.check_hostname is False assert ssl_context.verify_mode is ssl.CERT_NONE @@ -280,7 +278,10 @@ def test_trust_all_mock(config, mocker): def _assert_mock_tls_1_2(mock): mock.assert_called_once_with(ssl.PROTOCOL_TLS_CLIENT) - assert mock.return_value.minimum_version == ssl.TLSVersion.TLSv1_2 + if sys.version_info >= (3, 7): + assert mock.return_value.minimum_version == ssl.TLSVersion.TLSv1_2 + else: + assert mock.mock_calls[1][1][0] == ssl.OP_NO_TLSv1 @pytest.mark.parametrize("config", ( From 0d2bbfc687a814598481233f51893a79e568d0fd Mon Sep 17 00:00:00 2001 From: Prychantovskyi Date: Tue, 18 Oct 2022 16:15:37 +0100 Subject: [PATCH 04/20] Docker file edit. --- testkit/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testkit/Dockerfile b/testkit/Dockerfile index 4685d473..34d781a0 100644 --- a/testkit/Dockerfile +++ b/testkit/Dockerfile @@ -40,7 +40,7 @@ ENV PYENV_ROOT /.pyenv ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH # Setup python version -ENV PYTHON_VERSIONS 3.6 3.7 3.8 3.9 +ENV PYTHON_VERSIONS 3.6 3.7 3.8 3.9 3.10 RUN for version in $PYTHON_VERSIONS; do \ pyenv install $version:latest; \ From 503b612ba1c51a3c90d5d8905429d9f1cf260bf1 Mon Sep 17 00:00:00 2001 From: Prychantovskyi Date: Tue, 18 Oct 2022 17:09:55 +0100 Subject: [PATCH 05/20] Deleting -W Error part --- tox-unit.ini | 2 +- tox.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tox-unit.ini b/tox-unit.ini index d4d7664e..988bde17 100644 --- a/tox-unit.ini +++ b/tox-unit.ini @@ -11,6 +11,6 @@ deps = -r tests/requirements.txt commands = coverage erase - coverage run -m pytest -W error -v {posargs} \ + coverage run -m pytest -v {posargs} \ tests/unit coverage report diff --git a/tox.ini b/tox.ini index 15413083..d3e6e4eb 100644 --- a/tox.ini +++ b/tox.ini @@ -32,7 +32,7 @@ deps = -r tests/requirements.txt commands = coverage erase - coverage run -m pytest -W error -v {posargs} \ + coverage run -m pytest -v {posargs} \ tests/unit \ tests/stub \ tests/integration From 3bf620350d3743afb3eb6b008bc5147794931388 Mon Sep 17 00:00:00 2001 From: Prychantovskyi Date: Wed, 19 Oct 2022 09:57:22 +0100 Subject: [PATCH 06/20] Unmuting all, and muting import error --- tests/stub/conftest.py | 5 ++++- tox-unit.ini | 2 +- tox.ini | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/stub/conftest.py b/tests/stub/conftest.py index 6a9c4aa5..bed0fcd6 100644 --- a/tests/stub/conftest.py +++ b/tests/stub/conftest.py @@ -20,13 +20,16 @@ import subprocess +import warnings import os from platform import system from threading import Thread from time import sleep -from boltkit.server.stub import BoltStubService +with warnings.catch_warnings(): + warnings.simplefilter("ignore", ImportWarning) + from boltkit.server.stub import BoltStubService from pytest import fixture import logging diff --git a/tox-unit.ini b/tox-unit.ini index 988bde17..d4d7664e 100644 --- a/tox-unit.ini +++ b/tox-unit.ini @@ -11,6 +11,6 @@ deps = -r tests/requirements.txt commands = coverage erase - coverage run -m pytest -v {posargs} \ + coverage run -m pytest -W error -v {posargs} \ tests/unit coverage report diff --git a/tox.ini b/tox.ini index d3e6e4eb..15413083 100644 --- a/tox.ini +++ b/tox.ini @@ -32,7 +32,7 @@ deps = -r tests/requirements.txt commands = coverage erase - coverage run -m pytest -v {posargs} \ + coverage run -m pytest -W error -v {posargs} \ tests/unit \ tests/stub \ tests/integration From 925d90ef12db0f121abc0cacf7118da41ab30cd1 Mon Sep 17 00:00:00 2001 From: Prychantovskyi Date: Wed, 19 Oct 2022 10:57:52 +0100 Subject: [PATCH 07/20] Pandas import warning mute --- tests/unit/work/test_result.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/unit/work/test_result.py b/tests/unit/work/test_result.py index 7ce85ba4..d5eb0911 100644 --- a/tests/unit/work/test_result.py +++ b/tests/unit/work/test_result.py @@ -22,7 +22,9 @@ from unittest import mock import warnings -import pandas as pd +with warnings.catch_warnings(): + warnings.simplefilter("ignore", ImportWarning) + import pandas as pd import pytest from neo4j import ( From f10c56c57d275b79e806a3bd1e152ceed27d9ee7 Mon Sep 17 00:00:00 2001 From: Prychantovskyi Date: Wed, 19 Oct 2022 11:35:09 +0100 Subject: [PATCH 08/20] One more import warning mute --- tests/integration/conftest.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 015ba64d..281de639 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -25,6 +25,7 @@ from threading import RLock import pytest +import warnings import urllib from neo4j import ( @@ -76,7 +77,9 @@ def __init__(self, name=None, image=None, auth=None, n_cores=None, n_replicas=None, bolt_port=None, http_port=None, debug_port=None, debug_suspend=None, dir_spec=None, config=None): - from boltkit.legacy.controller import _install, create_controller + with warnings.catch_warnings(): + warnings.simplefilter("ignore", ImportWarning) + from boltkit.legacy.controller import _install, create_controller assert image.endswith("-enterprise") release = image[:-11] if release == "snapshot": From 2efeff7f93c0f92bd749d04ed41ff1762bb0c9f4 Mon Sep 17 00:00:00 2001 From: Prychantovskyi Date: Wed, 19 Oct 2022 13:02:03 +0100 Subject: [PATCH 09/20] One more deprecation warning mute --- tests/integration/conftest.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 281de639..1db718ad 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -192,7 +192,9 @@ def service(request): if existing_service: NEO4J_SERVICE = existing_service else: - NEO4J_SERVICE = Neo4jService(auth=NEO4J_AUTH, image=request.param, n_cores=NEO4J_CORES, n_replicas=NEO4J_REPLICAS) + with warnings.catch_warnings(): + warnings.simplefilter("ignore", DeprecationWarning) + NEO4J_SERVICE = Neo4jService(auth=NEO4J_AUTH, image=request.param, n_cores=NEO4J_CORES, n_replicas=NEO4J_REPLICAS) NEO4J_SERVICE.start(timeout=300) yield NEO4J_SERVICE if NEO4J_SERVICE is not None: From 6d9e9c838d20d0fa6eb4394ab7efd7755e102d8d Mon Sep 17 00:00:00 2001 From: Prychantovskyi Date: Wed, 19 Oct 2022 14:42:45 +0100 Subject: [PATCH 10/20] Cleaning --- neo4j/conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/neo4j/conf.py b/neo4j/conf.py index 8e4ec6ae..647f2ab8 100644 --- a/neo4j/conf.py +++ b/neo4j/conf.py @@ -156,7 +156,6 @@ def __update(self, data): def set_attr(k, v): if k in self.keys(): if k in self._deprecated_options(): - print("tebya ebut ") print(self._deprecated_options()) deprecation_warn("The '{}' config key is " "deprecated".format(k)) From 7b792dfdee5e8eb8c8e91ab4807e12189e6ca879 Mon Sep 17 00:00:00 2001 From: Prychantovskyi Date: Wed, 19 Oct 2022 14:53:40 +0100 Subject: [PATCH 11/20] Deprecated options line back --- neo4j/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/neo4j/conf.py b/neo4j/conf.py index 647f2ab8..ffd2fc5c 100644 --- a/neo4j/conf.py +++ b/neo4j/conf.py @@ -89,6 +89,7 @@ def __new__(mcs, name, bases, attributes): or isinstance(v, (staticmethod, classmethod))): fields.append(k) if isinstance(v, DeprecatedOption): + deprecated_options[k] = v.value attributes[k] = v.value def keys(_): From 60f2539241025799f1909e5aac0469492b3ef7be Mon Sep 17 00:00:00 2001 From: Prychantovskyi Date: Wed, 19 Oct 2022 14:56:46 +0100 Subject: [PATCH 12/20] Deprecated settings back --- tests/unit/test_conf.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/unit/test_conf.py b/tests/unit/test_conf.py index dbc13580..b7e22e63 100644 --- a/tests/unit/test_conf.py +++ b/tests/unit/test_conf.py @@ -78,6 +78,20 @@ config_function_names = ["consume_chain", "consume"] +@contextmanager +def _pool_config_deprecations(): + with pytest.warns(DeprecationWarning, + match="update_routing_table_timeout") as warnings: + yield warnings + + +@contextmanager +def _session_config_deprecations(): + with pytest.warns(DeprecationWarning, + match="session_connection_timeout") as warnings: + yield warnings + + def test_pool_config_consume(): test_config = dict(test_pool_config) From bce1b8af3b04cafa78327e804c7f072e41a69a98 Mon Sep 17 00:00:00 2001 From: Prychantovskyi Date: Wed, 19 Oct 2022 15:22:24 +0100 Subject: [PATCH 13/20] Test conf deprecation warnings mute --- tests/unit/test_conf.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/tests/unit/test_conf.py b/tests/unit/test_conf.py index b7e22e63..e6e74e8a 100644 --- a/tests/unit/test_conf.py +++ b/tests/unit/test_conf.py @@ -96,7 +96,9 @@ def test_pool_config_consume(): test_config = dict(test_pool_config) - consumed_pool_config = PoolConfig.consume(test_config) + with warnings.catch_warnings(): + warnings.simplefilter("ignore", DeprecationWarning) + consumed_pool_config = PoolConfig.consume(test_config) assert isinstance(consumed_pool_config, PoolConfig) @@ -133,7 +135,9 @@ def test_pool_config_consume_key_not_valid(): test_config["not_valid_key"] = "test" with pytest.raises(ConfigurationError) as error: - consumed_pool_config = PoolConfig.consume(test_config) + with warnings.catch_warnings(): + warnings.simplefilter("ignore", DeprecationWarning) + consumed_pool_config = PoolConfig.consume(test_config) error.match("Unexpected config keys: not_valid_key") @@ -142,7 +146,9 @@ def test_pool_config_set_value(): test_config = dict(test_pool_config) - consumed_pool_config = PoolConfig.consume(test_config) + with warnings.catch_warnings(): + warnings.simplefilter("ignore", DeprecationWarning) + consumed_pool_config = PoolConfig.consume(test_config) assert consumed_pool_config.get("encrypted") is False assert consumed_pool_config["encrypted"] is False @@ -160,7 +166,11 @@ def test_pool_config_set_value(): def test_pool_config_consume_and_then_consume_again(): test_config = dict(test_pool_config) - consumed_pool_config = PoolConfig.consume(test_config) + + with warnings.catch_warnings(): + warnings.simplefilter("ignore", DeprecationWarning) + consumed_pool_config = PoolConfig.consume(test_config) + assert consumed_pool_config.encrypted is False consumed_pool_config.encrypted = "test" @@ -181,7 +191,10 @@ def test_config_consume_chain(): test_config.update(test_session_config) - consumed_pool_config, consumed_session_config = Config.consume_chain(test_config, PoolConfig, SessionConfig) + with warnings.catch_warnings(): + warnings.simplefilter("ignore", DeprecationWarning) + consumed_pool_config, consumed_session_config = \ + Config.consume_chain(test_config, PoolConfig, SessionConfig) assert isinstance(consumed_pool_config, PoolConfig) assert isinstance(consumed_session_config, SessionConfig) From c4cb786f68bf53608e7bafa2caeb7b851aeb52e9 Mon Sep 17 00:00:00 2001 From: Prychantovskyi Date: Wed, 19 Oct 2022 15:45:22 +0100 Subject: [PATCH 14/20] Two consume test warning mute --- tests/unit/test_conf.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_conf.py b/tests/unit/test_conf.py index e6e74e8a..6898d0d9 100644 --- a/tests/unit/test_conf.py +++ b/tests/unit/test_conf.py @@ -177,8 +177,10 @@ def test_pool_config_consume_and_then_consume_again(): with pytest.raises(AttributeError): consumed_pool_config = PoolConfig.consume(consumed_pool_config) - consumed_pool_config = PoolConfig.consume(dict(consumed_pool_config.items())) - consumed_pool_config = PoolConfig.consume(dict(consumed_pool_config.items())) + with warnings.catch_warnings(): + warnings.simplefilter("ignore", DeprecationWarning) + consumed_pool_config = PoolConfig.consume(dict(consumed_pool_config.items())) + consumed_pool_config = PoolConfig.consume(dict(consumed_pool_config.items())) assert consumed_pool_config.encrypted == "test" From f6232dfd19456ad6918776f052fa75c95db61bf4 Mon Sep 17 00:00:00 2001 From: Prychantovskyi Date: Wed, 19 Oct 2022 16:21:16 +0100 Subject: [PATCH 15/20] Delete print --- neo4j/conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/neo4j/conf.py b/neo4j/conf.py index ffd2fc5c..d2a21786 100644 --- a/neo4j/conf.py +++ b/neo4j/conf.py @@ -157,7 +157,6 @@ def __update(self, data): def set_attr(k, v): if k in self.keys(): if k in self._deprecated_options(): - print(self._deprecated_options()) deprecation_warn("The '{}' config key is " "deprecated".format(k)) setattr(self, k, v) From b3834d34d7fac4e2f1fa23b714d8209bb57c6e99 Mon Sep 17 00:00:00 2001 From: Prychantovskyi Date: Thu, 20 Oct 2022 09:08:11 +0100 Subject: [PATCH 16/20] Little polishing and unmuting few warnings --- CHANGELOG.md | 2 +- TESTING.md | 2 +- neo4j/conf.py | 5 +++-- tests/integration/conftest.py | 2 +- tests/stub/conftest.py | 2 +- tests/unit/test_conf.py | 40 +++++++++++++++++++++-------------- 6 files changed, 31 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1294bc4..28c3b606 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Version 4.4.9 -- Python 3.10 support added (driver version 4.4.9) +- Python 3.10 support added ## Version 4.4 diff --git a/TESTING.md b/TESTING.md index d15dc3fb..93a4c9f2 100644 --- a/TESTING.md +++ b/TESTING.md @@ -1,7 +1,7 @@ # Neo4j Driver Testing To run driver tests, [Tox](https://tox.readthedocs.io) is required as well as at least one version of Python. -The versions of Python supported by this driver are CPython 3.6, 3.7, 3.8, 3.9 and 3.10. +The versions of Python supported by this driver are CPython 3.6, 3.7, 3.8, 3.9, and 3.10. ## Unit Tests & Stub Tests diff --git a/neo4j/conf.py b/neo4j/conf.py index d2a21786..3f3f365f 100644 --- a/neo4j/conf.py +++ b/neo4j/conf.py @@ -19,11 +19,10 @@ # limitations under the License. -import sys from abc import ABCMeta from collections.abc import Mapping +import sys import warnings -from warnings import warn from neo4j.meta import ( deprecation_warn, @@ -363,9 +362,11 @@ class SessionConfig(WorkspaceConfig): class TransactionConfig(Config): """ Transaction configuration. This is internal for now. + neo4j.session.begin_transaction neo4j.Query neo4j.unit_of_work + are both using the same settings. """ #: Metadata diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 1db718ad..518f3ac8 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -25,8 +25,8 @@ from threading import RLock import pytest -import warnings import urllib +import warnings from neo4j import ( GraphDatabase, diff --git a/tests/stub/conftest.py b/tests/stub/conftest.py index bed0fcd6..28e84e7a 100644 --- a/tests/stub/conftest.py +++ b/tests/stub/conftest.py @@ -20,8 +20,8 @@ import subprocess -import warnings import os +import warnings from platform import system from threading import Thread diff --git a/tests/unit/test_conf.py b/tests/unit/test_conf.py index 6898d0d9..786a77b1 100644 --- a/tests/unit/test_conf.py +++ b/tests/unit/test_conf.py @@ -20,10 +20,10 @@ from contextlib import contextmanager -import warnings - import ssl import sys +import warnings + import pytest from neo4j.exceptions import ( @@ -36,10 +36,10 @@ SessionConfig, ) from neo4j.api import ( - TRUST_SYSTEM_CA_SIGNED_CERTIFICATES, TRUST_ALL_CERTIFICATES, - WRITE_ACCESS, + TRUST_SYSTEM_CA_SIGNED_CERTIFICATES, READ_ACCESS, + WRITE_ACCESS, ) # python -m pytest tests/unit/test_conf.py -s -v @@ -96,9 +96,7 @@ def test_pool_config_consume(): test_config = dict(test_pool_config) - with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) - consumed_pool_config = PoolConfig.consume(test_config) + consumed_pool_config = PoolConfig.consume(test_config) assert isinstance(consumed_pool_config, PoolConfig) @@ -135,9 +133,11 @@ def test_pool_config_consume_key_not_valid(): test_config["not_valid_key"] = "test" with pytest.raises(ConfigurationError) as error: + # might or might not warn DeprecationWarning, but we're only + # interested in the error with warnings.catch_warnings(): warnings.simplefilter("ignore", DeprecationWarning) - consumed_pool_config = PoolConfig.consume(test_config) + _ = PoolConfig.consume(test_config) error.match("Unexpected config keys: not_valid_key") @@ -168,19 +168,27 @@ def test_pool_config_consume_and_then_consume_again(): test_config = dict(test_pool_config) with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) - consumed_pool_config = PoolConfig.consume(test_config) + with _pool_config_deprecations(): + warnings.simplefilter("ignore", DeprecationWarning) + consumed_pool_config = PoolConfig.consume(test_config) assert consumed_pool_config.encrypted is False consumed_pool_config.encrypted = "test" with pytest.raises(AttributeError): - consumed_pool_config = PoolConfig.consume(consumed_pool_config) - - with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) - consumed_pool_config = PoolConfig.consume(dict(consumed_pool_config.items())) - consumed_pool_config = PoolConfig.consume(dict(consumed_pool_config.items())) + _ = PoolConfig.consume(consumed_pool_config) + + with _pool_config_deprecations(): + consumed_pool_config = PoolConfig.consume( + dict(consumed_pool_config.items()) + ) + with _pool_config_deprecations(): + consumed_pool_config = PoolConfig.consume( + dict(consumed_pool_config.items()) + ) + + consumed_pool_config = PoolConfig.consume(dict(consumed_pool_config.items())) + consumed_pool_config = PoolConfig.consume(dict(consumed_pool_config.items())) assert consumed_pool_config.encrypted == "test" From 83d33b07711d704c301d8789f9f04a73d1557cda Mon Sep 17 00:00:00 2001 From: Prychantovskyi Date: Thu, 20 Oct 2022 10:28:46 +0100 Subject: [PATCH 17/20] Config tests rework --- tests/unit/test_conf.py | 61 +++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/tests/unit/test_conf.py b/tests/unit/test_conf.py index 786a77b1..8b593e10 100644 --- a/tests/unit/test_conf.py +++ b/tests/unit/test_conf.py @@ -81,15 +81,15 @@ @contextmanager def _pool_config_deprecations(): with pytest.warns(DeprecationWarning, - match="update_routing_table_timeout") as warnings: - yield warnings + match="update_routing_table_timeout") as warnings_: + yield warnings_ @contextmanager def _session_config_deprecations(): with pytest.warns(DeprecationWarning, - match="session_connection_timeout") as warnings: - yield warnings + match="session_connection_timeout") as warnings_: + yield warnings_ def test_pool_config_consume(): @@ -135,8 +135,7 @@ def test_pool_config_consume_key_not_valid(): with pytest.raises(ConfigurationError) as error: # might or might not warn DeprecationWarning, but we're only # interested in the error - with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) + with _pool_config_deprecations(): _ = PoolConfig.consume(test_config) error.match("Unexpected config keys: not_valid_key") @@ -146,8 +145,7 @@ def test_pool_config_set_value(): test_config = dict(test_pool_config) - with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) + with _pool_config_deprecations(): consumed_pool_config = PoolConfig.consume(test_config) assert consumed_pool_config.get("encrypted") is False @@ -167,10 +165,8 @@ def test_pool_config_consume_and_then_consume_again(): test_config = dict(test_pool_config) - with warnings.catch_warnings(): - with _pool_config_deprecations(): - warnings.simplefilter("ignore", DeprecationWarning) - consumed_pool_config = PoolConfig.consume(test_config) + with _pool_config_deprecations(): + consumed_pool_config = PoolConfig.consume(test_config) assert consumed_pool_config.encrypted is False consumed_pool_config.encrypted = "test" @@ -187,8 +183,14 @@ def test_pool_config_consume_and_then_consume_again(): dict(consumed_pool_config.items()) ) - consumed_pool_config = PoolConfig.consume(dict(consumed_pool_config.items())) - consumed_pool_config = PoolConfig.consume(dict(consumed_pool_config.items())) + with _pool_config_deprecations(): + consumed_pool_config = PoolConfig.consume( + dict(consumed_pool_config.items()) + ) + with _pool_config_deprecations(): + consumed_pool_config = PoolConfig.consume( + dict(consumed_pool_config.items()) + ) assert consumed_pool_config.encrypted == "test" @@ -228,19 +230,23 @@ def test_init_session_config_merge(): test_config_a = {"connection_acquisition_timeout": 111} test_config_c = {"max_transaction_retry_time": 222} - workspace_config = WorkspaceConfig(test_config_a, WorkspaceConfig.consume(test_config_c)) + workspace_config = WorkspaceConfig(test_config_a, + WorkspaceConfig.consume(test_config_c)) assert len(test_config_a) == 1 assert len(test_config_c) == 0 assert isinstance(workspace_config, WorkspaceConfig) - assert workspace_config.connection_acquisition_timeout == WorkspaceConfig.connection_acquisition_timeout + assert workspace_config.connection_acquisition_timeout == \ + WorkspaceConfig.connection_acquisition_timeout assert workspace_config.max_transaction_retry_time == 222 workspace_config = WorkspaceConfig(test_config_c, test_config_a) assert isinstance(workspace_config, WorkspaceConfig) assert workspace_config.connection_acquisition_timeout == 111 - assert workspace_config.max_transaction_retry_time == WorkspaceConfig.max_transaction_retry_time + assert workspace_config.max_transaction_retry_time == \ + WorkspaceConfig.max_transaction_retry_time - test_config_b = {"default_access_mode": READ_ACCESS, "connection_acquisition_timeout": 333} + test_config_b = {"default_access_mode": READ_ACCESS, + "connection_acquisition_timeout": 333} session_config = SessionConfig(workspace_config, test_config_b) assert session_config.connection_acquisition_timeout == 333 @@ -257,7 +263,11 @@ def test_init_session_config_with_not_valid_key(): test_config_a = {"connection_acquisition_timeout": 111} workspace_config = WorkspaceConfig.consume(test_config_a) - test_config_b = {"default_access_mode": READ_ACCESS, "connection_acquisition_timeout": 333, "not_valid_key": None} + test_config_b = { + "default_access_mode": READ_ACCESS, + "connection_acquisition_timeout": 333, + "not_valid_key": None + } session_config = SessionConfig(workspace_config, test_config_b) with pytest.raises(AttributeError): @@ -289,6 +299,7 @@ def test_no_ssl_mock(config, mocker): )) def test_trust_system_cas_mock(config, mocker): ssl_context_mock = mocker.patch("ssl.SSLContext", autospec=True) + ssl_context_mock.return_value.options = 0 pool_config = PoolConfig.consume(config) assert pool_config.encrypted is True ssl_context = pool_config.get_ssl_context() @@ -304,6 +315,7 @@ def test_trust_system_cas_mock(config, mocker): )) def test_trust_all_mock(config, mocker): ssl_context_mock = mocker.patch("ssl.SSLContext", autospec=True) + ssl_context_mock.return_value.options = 0 pool_config = PoolConfig.consume(config) assert pool_config.encrypted is True ssl_context = pool_config.get_ssl_context() @@ -318,7 +330,10 @@ def _assert_mock_tls_1_2(mock): if sys.version_info >= (3, 7): assert mock.return_value.minimum_version == ssl.TLSVersion.TLSv1_2 else: - assert mock.mock_calls[1][1][0] == ssl.OP_NO_TLSv1 + assert mock.return_value.options & ssl.OP_NO_TLSv1 + assert mock.return_value.options & ssl.OP_NO_TLSv1_1 + assert not mock.return_value.options & ssl.OP_NO_TLSv1_2 + assert not mock.return_value.options & ssl.OP_NO_TLSv1_3 @pytest.mark.parametrize("config", ( @@ -364,3 +379,9 @@ def _assert_context_tls_1_2(ctx): if sys.version_info >= (3, 7): assert ctx.protocol == ssl.PROTOCOL_TLS_CLIENT assert ctx.minimum_version == ssl.TLSVersion.TLSv1_2 + else: + assert ctx.protocol == ssl.PROTOCOL_TLS_CLIENT + assert ctx.options & ssl.OP_NO_TLSv1 + assert ctx.options & ssl.OP_NO_TLSv1_1 + assert not ctx.options & ssl.OP_NO_TLSv1_2 + assert not ctx.options & ssl.OP_NO_TLSv1_3 From 90e7d9c06c14d4421dad6f390158e341e352efd7 Mon Sep 17 00:00:00 2001 From: Prychantovskyi Date: Thu, 20 Oct 2022 10:56:22 +0100 Subject: [PATCH 18/20] One more warning --- tests/unit/test_conf.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/unit/test_conf.py b/tests/unit/test_conf.py index 8b593e10..9d78be12 100644 --- a/tests/unit/test_conf.py +++ b/tests/unit/test_conf.py @@ -96,7 +96,8 @@ def test_pool_config_consume(): test_config = dict(test_pool_config) - consumed_pool_config = PoolConfig.consume(test_config) + with _pool_config_deprecations(): + consumed_pool_config = PoolConfig.consume(test_config) assert isinstance(consumed_pool_config, PoolConfig) From e4d4feea3f836521860095396e872d41798d5ca4 Mon Sep 17 00:00:00 2001 From: Robsdedude Date: Fri, 21 Oct 2022 11:38:04 +0200 Subject: [PATCH 19/20] Some formatting --- tests/unit/test_conf.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/tests/unit/test_conf.py b/tests/unit/test_conf.py index 9d78be12..0d58bd48 100644 --- a/tests/unit/test_conf.py +++ b/tests/unit/test_conf.py @@ -184,24 +184,13 @@ def test_pool_config_consume_and_then_consume_again(): dict(consumed_pool_config.items()) ) - with _pool_config_deprecations(): - consumed_pool_config = PoolConfig.consume( - dict(consumed_pool_config.items()) - ) - with _pool_config_deprecations(): - consumed_pool_config = PoolConfig.consume( - dict(consumed_pool_config.items()) - ) - assert consumed_pool_config.encrypted == "test" def test_config_consume_chain(): test_config = {} - test_config.update(test_pool_config) - test_config.update(test_session_config) with warnings.catch_warnings(): @@ -267,7 +256,7 @@ def test_init_session_config_with_not_valid_key(): test_config_b = { "default_access_mode": READ_ACCESS, "connection_acquisition_timeout": 333, - "not_valid_key": None + "not_valid_key": None, } session_config = SessionConfig(workspace_config, test_config_b) From 9ae3859f3bbab022797af688c5419ebc58322b09 Mon Sep 17 00:00:00 2001 From: Robsdedude Date: Fri, 21 Oct 2022 11:51:15 +0200 Subject: [PATCH 20/20] Re-introduce tests for deprecated config options + import order --- tests/integration/conftest.py | 7 ++----- tests/unit/test_conf.py | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 518f3ac8..55526f18 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -25,14 +25,11 @@ from threading import RLock import pytest -import urllib import warnings -from neo4j import ( - GraphDatabase, -) -from neo4j.exceptions import ServiceUnavailable +from neo4j import GraphDatabase from neo4j._exceptions import BoltHandshakeError +from neo4j.exceptions import ServiceUnavailable from neo4j.io import Bolt # import logging diff --git a/tests/unit/test_conf.py b/tests/unit/test_conf.py index 0d58bd48..e1b51d51 100644 --- a/tests/unit/test_conf.py +++ b/tests/unit/test_conf.py @@ -36,9 +36,9 @@ SessionConfig, ) from neo4j.api import ( + READ_ACCESS, TRUST_ALL_CERTIFICATES, TRUST_SYSTEM_CA_SIGNED_CERTIFICATES, - READ_ACCESS, WRITE_ACCESS, ) @@ -269,6 +269,24 @@ def test_init_session_config_with_not_valid_key(): assert session_config.connection_acquisition_timeout == 333 +def test_pool_config_deprecated_update_routing_table_timeout(): + with _pool_config_deprecations(): + _ = PoolConfig.consume({"update_routing_table_timeout": 1}) + + with warnings.catch_warnings(): + warnings.simplefilter("error") + _ = PoolConfig.consume({}) + + +def test_session_config_deprecated_session_connection_timeout(): + with _session_config_deprecations(): + _ = SessionConfig.consume({"session_connection_timeout": 1}) + + with warnings.catch_warnings(): + warnings.simplefilter("error") + _ = SessionConfig.consume({}) + + @pytest.mark.parametrize("config", ( {}, {"encrypted": False},