Mongo clients with the same settings should be shared since they manage a connection pool.

Also, I removed old code that was supposed to support Pymongo<2.1 which we don't support anymore.
This commit is contained in:
Omer Katz
2014-06-25 16:53:24 +03:00
parent f099dc6a37
commit 29309dac9a
2 changed files with 29 additions and 15 deletions

View File

@@ -34,6 +34,17 @@ class ConnectionTest(unittest.TestCase):
conn = get_connection('testdb')
self.assertTrue(isinstance(conn, pymongo.mongo_client.MongoClient))
def test_sharing_connections(self):
"""Ensure that connections are shared when the connection settings are exactly the same
"""
connect('mongoenginetest', alias='testdb1')
expected_connection = get_connection('testdb1')
connect('mongoenginetest', alias='testdb2')
actual_connection = get_connection('testdb2')
self.assertIs(expected_connection, actual_connection)
def test_connect_uri(self):
"""Ensure that the connect() method works properly with uri's
"""