commit
df52ed1162
@ -45,13 +45,13 @@ def register_connection(alias, name, host='localhost', port=27017,
|
|||||||
if uri_dict.get('database') is None:
|
if uri_dict.get('database') is None:
|
||||||
raise ConnectionError("If using URI style connection include "\
|
raise ConnectionError("If using URI style connection include "\
|
||||||
"database name in string")
|
"database name in string")
|
||||||
uri_dict['name'] = uri_dict.get('database')
|
|
||||||
_connection_settings[alias] = {
|
_connection_settings[alias] = {
|
||||||
'host': host,
|
'host': host,
|
||||||
'name': uri_dict.get('database'),
|
'name': uri_dict.get('database'),
|
||||||
'username': uri_dict.get('username'),
|
'username': uri_dict.get('username'),
|
||||||
'password': uri_dict.get('password')
|
'password': uri_dict.get('password')
|
||||||
}
|
}
|
||||||
|
_connection_settings[alias].update(kwargs)
|
||||||
return
|
return
|
||||||
|
|
||||||
_connection_settings[alias] = {
|
_connection_settings[alias] = {
|
||||||
@ -64,7 +64,6 @@ def register_connection(alias, name, host='localhost', port=27017,
|
|||||||
'password': password,
|
'password': password,
|
||||||
'read_preference': read_preference
|
'read_preference': read_preference
|
||||||
}
|
}
|
||||||
|
|
||||||
_connection_settings[alias].update(kwargs)
|
_connection_settings[alias].update(kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class ConnectionTest(unittest.TestCase):
|
|||||||
c.admin.authenticate("admin", "password")
|
c.admin.authenticate("admin", "password")
|
||||||
c.mongoenginetest.add_user("username", "password")
|
c.mongoenginetest.add_user("username", "password")
|
||||||
|
|
||||||
self.assertRaises(ConnectionError, connect, "testdb_uri_bad", host='mongodb://test:password@localhost/mongoenginetest')
|
self.assertRaises(ConnectionError, connect, "testdb_uri_bad", host='mongodb://test:password@localhost')
|
||||||
|
|
||||||
connect("testdb_uri", host='mongodb://username:password@localhost/mongoenginetest')
|
connect("testdb_uri", host='mongodb://username:password@localhost/mongoenginetest')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user