Skip to content

Commit 82680df

Browse files
author
shai-katzir-hs
authored
Merge pull request #4 from HiredScore/DEV-23298-upgrade-pymongo
Fix pymongo compatability
2 parents 1f2055a + cc469da commit 82680df

File tree

4 files changed

+3
-27
lines changed

4 files changed

+3
-27
lines changed

celery/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
SERIES = 'cliffs'
2222

23-
__version__ = '4.5.0'
23+
__version__ = '4.5.0.1'
2424
__author__ = 'Ask Solem'
2525
__contact__ = '[email protected]'
2626
__homepage__ = 'http://celeryproject.org'

celery/backends/mongodb.py

+1-10
Original file line numberDiff line numberDiff line change
@@ -274,16 +274,7 @@ def __reduce__(self, args=(), kwargs=None):
274274

275275
def _get_database(self):
276276
conn = self._get_connection()
277-
db = conn[self.database_name]
278-
if self.user and self.password:
279-
source = self.options.get(
280-
'authsource',
281-
self.database_name or 'admin'
282-
)
283-
if not db.authenticate(self.user, self.password, source=source):
284-
raise ImproperlyConfigured(
285-
'Invalid MongoDB username or password.')
286-
return db
277+
return conn[self.database_name]
287278

288279
@cached_property
289280
def database(self):

requirements/extras/mongodb.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pymongo[srv]>=3.3.0
1+
pymongo[srv]>=3.11.1

t/unit/backends/test_mongodb.py

-15
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,6 @@ def test_get_database_no_existing(self, mock_get_connection):
277277

278278
assert database is mock_database
279279
assert self.backend.__dict__['database'] is mock_database
280-
mock_database.authenticate.assert_called_once_with(
281-
MONGODB_USER, MONGODB_PASSWORD, source=self.backend.database_name)
282280

283281
@patch('celery.backends.mongodb.MongoBackend._get_connection')
284282
def test_get_database_no_existing_no_auth(self, mock_get_connection):
@@ -294,7 +292,6 @@ def test_get_database_no_existing_no_auth(self, mock_get_connection):
294292
database = self.backend.database
295293

296294
assert database is mock_database
297-
mock_database.authenticate.assert_not_called()
298295
assert self.backend.__dict__['database'] is mock_database
299296

300297
@patch('celery.backends.mongodb.MongoBackend._get_database')
@@ -487,18 +484,6 @@ def test_cleanup(self, mock_get_database):
487484
mock_get_database.assert_called_once_with()
488485
mock_collection.delete_many.assert_called()
489486

490-
def test_get_database_authfailure(self):
491-
x = MongoBackend(app=self.app)
492-
x._get_connection = Mock()
493-
conn = x._get_connection.return_value = {}
494-
db = conn[x.database_name] = Mock()
495-
db.authenticate.return_value = False
496-
x.user = 'jerry'
497-
x.password = 'cere4l'
498-
with pytest.raises(ImproperlyConfigured):
499-
x._get_database()
500-
db.authenticate.assert_called_with('jerry', 'cere4l',
501-
source=x.database_name)
502487

503488
def test_prepare_client_options(self):
504489
with patch('pymongo.version_tuple', new=(3, 0, 3)):

0 commit comments

Comments
 (0)