Skip to content

Commit a73ee00

Browse files
committed
Make tests compatible with pymongo >= 4.14
mongodb/mongo-python-driver#2413 caused some test regressions here. This isn't currently a problem for the upstream test suite since it pins pymongo==4.10.1 via kombu, but we're running into it in Debian where we've already upgraded pymongo for other reasons. kombu already tried to upgrade pymongo but had to revert due to these test regressions (see celery/kombu#2384 and celery#9938). One of the test fixes (relating to `mongodb_backend_settings`) illustrates an incompatibility where I couldn't figure out a reasonable way to avoid passing it through to Celery users, so I added a note to the documentation about it. It may also be worth including a brief mention of it in the release notes. Using the canonical case for the option in question should work with both old and new versions of pymongo.
1 parent 2731860 commit a73ee00

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

docs/userguide/configuration.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,12 @@ This is a dict supporting the following keys:
12081208
constructor. See the :mod:`pymongo` docs to see a list of arguments
12091209
supported.
12101210

1211+
.. note::
1212+
1213+
With pymongo>=4.14, options are case-sensitive when they were previously
1214+
case-insensitive. See :class:`~pymongo.mongo_client.MongoClient` to
1215+
determine the correct case.
1216+
12111217
.. _example-mongodb-result-config:
12121218

12131219
Example configuration

t/unit/backends/test_mongodb.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,15 @@ def test_init_with_settings(self):
132132
assert mb.mongo_host == MONGODB_BACKEND_HOST
133133
assert mb.options == dict(
134134
mb._prepare_client_options(),
135-
replicaset='rs0',
135+
replicaSet='rs0',
136136
)
137137
assert mb.user == CELERY_USER
138138
assert mb.password == CELERY_PASSWORD
139139
assert mb.database_name == CELERY_DATABASE
140140

141141
# same uri, change some parameters in backend settings
142142
self.app.conf.mongodb_backend_settings = {
143-
'replicaset': 'rs1',
143+
'replicaSet': 'rs1',
144144
'user': 'backenduser',
145145
'database': 'another_db',
146146
'options': {
@@ -151,7 +151,7 @@ def test_init_with_settings(self):
151151
assert mb.mongo_host == MONGODB_BACKEND_HOST
152152
assert mb.options == dict(
153153
mb._prepare_client_options(),
154-
replicaset='rs1',
154+
replicaSet='rs1',
155155
socketKeepAlive=True,
156156
)
157157
assert mb.user == 'backenduser'
@@ -224,7 +224,7 @@ def test_init_mongodb_dnspython2_pymongo4_seedlist(self):
224224
mb = self.perform_seedlist_assertions()
225225
assert mb.options == dict(
226226
mb._prepare_client_options(),
227-
replicaset='rs0',
227+
replicaSet='rs0',
228228
tls=True
229229
)
230230

@@ -303,7 +303,7 @@ def test_get_connection_with_authmechanism(self):
303303
host=['localhost:27017'],
304304
username=CELERY_USER,
305305
password=CELERY_PASSWORD,
306-
authmechanism='SCRAM-SHA-256',
306+
authMechanism='SCRAM-SHA-256',
307307
**mb._prepare_client_options()
308308
)
309309
assert sentinel.connection == connection
@@ -321,7 +321,7 @@ def test_get_connection_with_authmechanism_no_username(self):
321321
mb._get_connection()
322322
mock_Connection.assert_called_once_with(
323323
host=['localhost:27017'],
324-
authmechanism='SCRAM-SHA-256',
324+
authMechanism='SCRAM-SHA-256',
325325
**mb._prepare_client_options()
326326
)
327327

0 commit comments

Comments
 (0)