fix the way MongoDB URI w/ ?replicaset is passed
This commit is contained in:
parent
a4d0da0085
commit
65914fb2b2
@ -96,7 +96,7 @@ def register_connection(alias, name=None, host=None, port=None,
|
|||||||
|
|
||||||
uri_options = uri_dict['options']
|
uri_options = uri_dict['options']
|
||||||
if 'replicaset' in uri_options:
|
if 'replicaset' in uri_options:
|
||||||
conn_settings['replicaSet'] = True
|
conn_settings['replicaSet'] = uri_options['replicaset']
|
||||||
if 'authsource' in uri_options:
|
if 'authsource' in uri_options:
|
||||||
conn_settings['authentication_source'] = uri_options['authsource']
|
conn_settings['authentication_source'] = uri_options['authsource']
|
||||||
if 'authmechanism' in uri_options:
|
if 'authmechanism' in uri_options:
|
||||||
|
@ -200,6 +200,13 @@ class ConnectionTest(unittest.TestCase):
|
|||||||
self.assertTrue(isinstance(db, pymongo.database.Database))
|
self.assertTrue(isinstance(db, pymongo.database.Database))
|
||||||
self.assertEqual(db.name, 'test')
|
self.assertEqual(db.name, 'test')
|
||||||
|
|
||||||
|
def test_connect_uri_with_replicaset(self):
|
||||||
|
"""Ensure connect() works when specifying a replicaSet."""
|
||||||
|
c = connect(host='mongodb://localhost/test?replicaSet=local-rs')
|
||||||
|
db = get_db()
|
||||||
|
self.assertTrue(isinstance(db, pymongo.database.Database))
|
||||||
|
self.assertEqual(db.name, 'test')
|
||||||
|
|
||||||
def test_uri_without_credentials_doesnt_override_conn_settings(self):
|
def test_uri_without_credentials_doesnt_override_conn_settings(self):
|
||||||
"""Ensure connect() uses the username & password params if the URI
|
"""Ensure connect() uses the username & password params if the URI
|
||||||
doesn't explicitly specify them.
|
doesn't explicitly specify them.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user