minimongo
minimongo copied to clipboard
Feature request: mongomock compatibility
I've just encountered minimongo and it looks really great, but I don't think it will work with e.g. mongomock out of the box. mongomock is a drop-in substitute for pymongo which doesn't use a real mongodb backend but performs operations in-memory (not necessarily efficiently) so that you don't need the hassle of setting up a real mongodb instance for unit testing.
As an example:
>>> import mongomock
>>> client = mongomock.MongoClient()
>>> client.db.collection.insert({'foo': 'bar'})
ObjectId('586651608eda9b078e37499e')
>>> list(client.db.collection.find({}))
[{'foo': 'bar', '_id': ObjectId('586651608eda9b078e37499e')}]
It would seem better if minimongo wrapped around an existing MongoDB client (which could then be either a pymongo or a mongomock client) or an existing MongoDB database (ditto).
FWIW Mongo-Thingy now supports Mongomock out of the box, and I found the idea here, so thank you @vegard!