Log In
Log In
Places
All Projects
Status Monitor
Collapse sidebar
matrix-synapse
python-mongodict
python-mongodict-0.3.1-newer-pymongo.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File python-mongodict-0.3.1-newer-pymongo.patch of Package python-mongodict
diff --git a/mongodict.py b/mongodict.py index 33e6ec1..1195f57 100644 --- a/mongodict.py +++ b/mongodict.py @@ -53,9 +53,9 @@ class MongoDict(MutableMapping): Create a new MongoDB connection. `auth` must be (login, password)''' super(MongoDict, self).__init__() - self._connection = pymongo.Connection(host=host, port=port, safe=safe) + self._client = pymongo.MongoClient(host=host, port=port) self._safe = safe - self._db = self._connection[database] + self._db = self._client[database] if auth is not None: # TODO: test auth if not self._db.authenticate(*auth): raise ValueError('Cannot authenticate to MongoDB server.') @@ -107,7 +107,7 @@ class MongoDict(MutableMapping): def clear(self): ''' Delete all key/value pairs ''' - self._collection.remove({}, safe=self._safe) + self._collection.remove({}) def __len__(self): ''' Return how many key/value pairs are stored ''' @@ -127,5 +127,5 @@ class MongoDict(MutableMapping): def __del__(self): ''' Sync all operations and disconnect ''' - self._connection.fsync() - self._connection.disconnect() + self._client.fsync() + self._client.close() diff --git a/tests/test_mapping_protocol.py b/tests/test_mapping_protocol.py index e86f208..8d170e3 100644 --- a/tests/test_mapping_protocol.py +++ b/tests/test_mapping_protocol.py @@ -26,8 +26,8 @@ def random_string(length=32): class TestMappingProtocol(mapping_tests.BasicTestMappingProtocol): def setUp(self): - self._connection = pymongo.Connection(host=MONGO_HOST, port=MONGO_PORT) - self._db = self._connection[MONGO_DATABASE] + self._client = pymongo.MongoClient(host=MONGO_HOST, port=MONGO_PORT) + self._db = self._client[MONGO_DATABASE] self.collections = [] def tearDown(self): diff --git a/tests/test_mongodict.py b/tests/test_mongodict.py index b076c0b..b66626c 100644 --- a/tests/test_mongodict.py +++ b/tests/test_mongodict.py @@ -40,13 +40,13 @@ class TestMongoDict(unittest.TestCase): self.config = {'host': 'localhost', 'port': 27017, 'database': 'mongodict', 'collection': 'main',} # as no codec is specified, it uses the default (pickle) - self.connection = pymongo.Connection(host=self.config['host'], - port=self.config['port'], safe=True) - self.db = self.connection[self.config['database']] + self.client = pymongo.MongoClient(host=self.config['host'], + port=self.config['port']) + self.db = self.client[self.config['database']] self.collection = self.db[self.config['collection']] def tearDown(self): - self.connection.drop_database(self.db) + self.client.drop_database(self.db) def test_set_item_should_save_data_in_collection(self): my_dict = MongoDict(**self.config)
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Contact
Support
@OBShq
The Open Build Service is an
openSUSE project
.
Log In
Places
Places
All Projects
Status Monitor