Replace use close method in pymongo
This commit is contained in:
parent
9c8ceb6b4e
commit
96cfbb201a
@ -81,7 +81,7 @@ def disconnect(alias=DEFAULT_CONNECTION_NAME):
|
|||||||
global _dbs
|
global _dbs
|
||||||
|
|
||||||
if alias in _connections:
|
if alias in _connections:
|
||||||
get_connection(alias=alias).disconnect()
|
get_connection(alias=alias).close()
|
||||||
del _connections[alias]
|
del _connections[alias]
|
||||||
if alias in _dbs:
|
if alias in _dbs:
|
||||||
del _dbs[alias]
|
del _dbs[alias]
|
||||||
|
@ -51,6 +51,14 @@ class ConnectionTest(unittest.TestCase):
|
|||||||
conn = get_connection('testdb')
|
conn = get_connection('testdb')
|
||||||
self.assertTrue(isinstance(conn, pymongo.mongo_client.MongoClient))
|
self.assertTrue(isinstance(conn, pymongo.mongo_client.MongoClient))
|
||||||
|
|
||||||
|
def test_disconnect(self):
|
||||||
|
"""Ensure that the disconnect() method works properly
|
||||||
|
"""
|
||||||
|
conn1 = connect('mongoenginetest')
|
||||||
|
mongoengine.connection.disconnect()
|
||||||
|
conn2 = connect('mongoenginetest')
|
||||||
|
self.assertTrue(conn1 is not conn2)
|
||||||
|
|
||||||
def test_sharing_connections(self):
|
def test_sharing_connections(self):
|
||||||
"""Ensure that connections are shared when the connection settings are exactly the same
|
"""Ensure that connections are shared when the connection settings are exactly the same
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user