Skip to content

Commit 277979a

Browse files
authored
Merge branch 'main' into dependabot/pip/flake8-7.2.0
2 parents 0a71ff0 + 37d4205 commit 277979a

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

kombu/transport/mongodb.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,9 @@ def _parse_uri(self, scheme='mongodb://'):
305305

306306
port = client.port if client.port else self.default_port
307307

308-
parsed = uri_parser.parse_uri(hostname, port)
308+
# We disable validating and normalization parameters here,
309+
# because pymongo will validate and normalize parameters later in __init__ of MongoClient
310+
parsed = uri_parser.parse_uri(hostname, port, validate=False)
309311

310312
dbname = parsed['database'] or client.virtual_host
311313

t/unit/transport/test_mongodb.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,18 @@ def test_correct_readpreference(self):
116116
hostname, dbname, options = channel._parse_uri()
117117
assert options['readpreference'] == 'nearest'
118118

119+
def test_normalizes_params_from_uri_only_once(self):
120+
channel = _create_mock_connection('mongodb://localhost/?serverselectiontimeoutms=1000').default_channel
121+
122+
def server_info(self):
123+
return {'version': '3.6.0-rc'}
124+
125+
with patch.object(pymongo.MongoClient, 'server_info', server_info):
126+
database = channel._open()
127+
128+
client_options = database.client.options
129+
assert client_options.server_selection_timeout == 1.0
130+
119131

120132
class BaseMongoDBChannelCase:
121133

0 commit comments

Comments
 (0)