From 96cfbb201abd09e6f4c824a8bc771b2f2b235be2 Mon Sep 17 00:00:00 2001 From: Emmanuel Leblond Date: Tue, 4 Aug 2015 18:02:57 +0200 Subject: [PATCH] Replace use close method in pymongo --- mongoengine/connection.py | 2 +- tests/test_connection.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/mongoengine/connection.py b/mongoengine/connection.py index cb1a731f..5f62d6cf 100644 --- a/mongoengine/connection.py +++ b/mongoengine/connection.py @@ -81,7 +81,7 @@ def disconnect(alias=DEFAULT_CONNECTION_NAME): global _dbs if alias in _connections: - get_connection(alias=alias).disconnect() + get_connection(alias=alias).close() del _connections[alias] if alias in _dbs: del _dbs[alias] diff --git a/tests/test_connection.py b/tests/test_connection.py index e9477b79..1b7b7a22 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -51,6 +51,14 @@ class ConnectionTest(unittest.TestCase): conn = get_connection('testdb') 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): """Ensure that connections are shared when the connection settings are exactly the same """