From 9055bb09e63d8598f0bdff1d11a7e734d8438504 Mon Sep 17 00:00:00 2001 From: Prashant Mital <5883388+prashantmital@users.noreply.github.com> Date: Fri, 20 Aug 2021 10:17:06 -0700 Subject: [PATCH] PYTHON-2702 Remove deprecated URI options (#710) --- doc/migrate-to-pymongo4.rst | 51 ++++++++++++++++++++----------------- pymongo/common.py | 8 ++---- test/test_common.py | 2 +- test/test_uri_parser.py | 4 +-- 4 files changed, 33 insertions(+), 32 deletions(-) diff --git a/doc/migrate-to-pymongo4.rst b/doc/migrate-to-pymongo4.rst index a7dd6570d..658d53724 100644 --- a/doc/migrate-to-pymongo4.rst +++ b/doc/migrate-to-pymongo4.rst @@ -89,29 +89,34 @@ The old option names and their renamed equivalents are summarized in the table below. Some renamed options have different semantics from the option being replaced as noted in the 'Migration Notes' column. -+--------------------+-------------------------------+-------------------------------------------------------------+ -| Old URI Option | Renamed URI Option | Migration Notes | -+====================+===============================+=============================================================+ -| ssl_pem_passphrase | tlsCertificateKeyFilePassword | - | -+--------------------+-------------------------------+-------------------------------------------------------------+ -| ssl_ca_certs | tlsCAFile | - | -+--------------------+-------------------------------+-------------------------------------------------------------+ -| ssl_crlfile | tlsCRLFile | - | -+--------------------+-------------------------------+-------------------------------------------------------------+ -| ssl_match_hostname | tlsAllowInvalidHostnames | ``ssl_match_hostname=True`` is equivalent to | -| | | ``tlsAllowInvalidHostnames=False`` and vice-versa. | -+--------------------+-------------------------------+-------------------------------------------------------------+ -| ssl_cert_reqs | tlsAllowInvalidCertificates | Instead of ``ssl.CERT_NONE``, ``ssl.CERT_OPTIONAL`` | -| | | and ``ssl.CERT_REQUIRED``, ``tlsAllowInvalidCertificates`` | -| | | expects a boolean value - ``True`` is equivalent to | -| | | ``ssl.CERT_NONE``, while ``False`` is equivalent to | -| | | ``ssl.CERT_REQUIRED``. | -+--------------------+-------------------------------+-------------------------------------------------------------+ -| ssl_certfile | tlsCertificateKeyFile | Instead of using ``ssl_certfile`` and ``ssl_keyfile`` | -| | | to specify the certificate and private key files, | -+--------------------+ | ``tlsCertificateKeyFile`` expects a single file containing | -| ssl_keyfile | | both the client certificate and the private key. | -+--------------------+-------------------------------+-------------------------------------------------------------+ ++--------------------+-------------------------------+--------------------------------------------------------+ +| Old URI Option | Renamed URI Option | Migration Notes | ++====================+===============================+========================================================+ +| ssl_pem_passphrase | tlsCertificateKeyFilePassword | - | ++--------------------+-------------------------------+--------------------------------------------------------+ +| ssl_ca_certs | tlsCAFile | - | ++--------------------+-------------------------------+--------------------------------------------------------+ +| ssl_crlfile | tlsCRLFile | - | ++--------------------+-------------------------------+--------------------------------------------------------+ +| ssl_match_hostname | tlsAllowInvalidHostnames | ``ssl_match_hostname=True`` is equivalent to | +| | | ``tlsAllowInvalidHostnames=False`` and vice-versa. | ++--------------------+-------------------------------+--------------------------------------------------------+ +| ssl_cert_reqs | tlsAllowInvalidCertificates | Instead of ``ssl.CERT_NONE``, ``ssl.CERT_OPTIONAL`` | +| | | and ``ssl.CERT_REQUIRED``, the new option expects | +| | | a boolean value - ``True`` is equivalent to | +| | | ``ssl.CERT_NONE``, while ``False`` is equivalent to | +| | | ``ssl.CERT_REQUIRED``. | ++--------------------+-------------------------------+--------------------------------------------------------+ +| ssl_certfile | tlsCertificateKeyFile | Instead of using ``ssl_certfile`` and ``ssl_keyfile`` | +| | | to specify the certificate and private key files | ++--------------------+ | respectively, use ``tlsCertificateKeyFile`` to pass | +| ssl_keyfile | | a single file containing both the client certificate | +| | | and the private key. | ++--------------------+-------------------------------+--------------------------------------------------------+ +| j | journal | - | ++--------------------+-------------------------------+--------------------------------------------------------+ +| wtimeout | wTimeoutMS | - | ++--------------------+-------------------------------+--------------------------------------------------------+ MongoClient.fsync is removed ............................ diff --git a/pymongo/common.py b/pymongo/common.py index 79c50f77a..b465e3816 100644 --- a/pymongo/common.py +++ b/pymongo/common.py @@ -585,8 +585,6 @@ def validate_tzinfo(dummy, value): # Dictionary where keys are the names of public URI options, and values # are lists of aliases for that option. URI_OPTIONS_ALIAS_MAP = { - 'journal': ['j'], - 'wtimeoutms': ['wtimeout'], 'tls': ['ssl'], } @@ -666,8 +664,6 @@ KW_VALIDATORS = { # variant need not be included here. Options whose public and internal # names are the same need not be included here. INTERNAL_URI_OPTION_NAME_MAP = { - 'j': 'journal', - 'wtimeout': 'wtimeoutms', 'ssl': 'tls', } @@ -681,8 +677,8 @@ URI_OPTIONS_DEPRECATION_MAP = { # preserved for renamed options as they are part of user warnings. # - 'removed': may suggest the rationale for deprecating the # option and/or recommend remedial action. - 'j': ('renamed', 'journal'), - 'wtimeout': ('renamed', 'wTimeoutMS'), + # For example: + # 'wtimeout': ('renamed', 'wTimeoutMS'), } # Augment the option validator map with pymongo-specific option information. diff --git a/test/test_common.py b/test/test_common.py index c6ab4182d..87b5ce4c9 100644 --- a/test/test_common.py +++ b/test/test_common.py @@ -110,7 +110,7 @@ class TestCommon(IntegrationTest): c = rs_or_single_client(connect=False) self.assertEqual(WriteConcern(), c.write_concern) - c = rs_or_single_client(connect=False, w=2, wtimeout=1000) + c = rs_or_single_client(connect=False, w=2, wTimeoutMS=1000) wc = WriteConcern(w=2, wtimeout=1000) self.assertEqual(wc, c.write_concern) diff --git a/test/test_uri_parser.py b/test/test_uri_parser.py index bd862642c..de98b9a41 100644 --- a/test/test_uri_parser.py +++ b/test/test_uri_parser.py @@ -476,8 +476,8 @@ class TestURI(unittest.TestCase): def test_normalize_options(self): # check that options are converted to their internal names correctly. - uri = ("mongodb://example.com/?ssl=true&appname=myapp&wtimeout=10") - res = {"tls": True, "appname": "myapp", "wtimeoutms": 10} + uri = ("mongodb://example.com/?ssl=true&appname=myapp") + res = {"tls": True, "appname": "myapp"} self.assertEqual(res, parse_uri(uri)["options"]) def test_unquote_after_parsing(self):