Mongoengine: "Use insert_one" commit in 0.16.1 breaks mongomock support

Created on 14 Nov 2018  路  8Comments  路  Source: MongoEngine/mongoengine

Hi,

this morning my build pipeline started failing with these errors:

  File "/app/tests/test_mongo.py", line 57, in setUp
    ExampleTopping('pineapple', amount=10)])
  File mongoengine/queryset/base.py", line 288, in create
    return self._document(**kwargs).save(force_insert=True)
  File "mongoengine/document.py", line 379, in save
    object_id = self._save_create(doc, force_insert, write_concern)
  File "mongoengine/document.py", line 431, in _save_create
    with set_write_concern(collection, write_concern) as wc_collection:
  File "python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "mongoengine/context_managers.py", line 247, in set_write_concern
    yield collection.with_options(write_concern=WriteConcern(**combined_concerns))
  File "mongomock/collection.py", line 1961, in with_options
    'in Mongomock' % key)
NotImplementedError: write_concern is a valid parameter for with_options but it is currently not implemented in Mongomock

Versions:
mongoengine==0.16.1
mongomock==3.13.0

It used to work with 0.16.0. Looks like the NotImplementedError gets triggered by 34e3e45843ef0475824b79b3405285a2d75d7648.

I'm aware that you needn't model your changes after mongomock, but you may want to be aware of this. If there is an alternative fix I should be using, I'm happy hear.

Cheers!

Most helpful comment

I have just released mongomock v3.14.0 which should solve that issue.

All 8 comments

FYI @erdenezul

I don't think it is mongoengine problem at all. U have to specify mongoengine>=0.16.1,<0.16.2 or something

@bagerard I want to hear your opinion too

or we could stay old pymongo2 method when using pymongo2.

I have posed an issue with mongomock to see if it can get addressed there:
https://github.com/mongomock/mongomock/issues/465

I have just released mongomock v3.14.0 which should solve that issue.

@wdoekes Could please test mongoengine==0.16.1 and mongomock==3.14.0

:ok_hand: works.

Thanks for the quick fixes, @pcorpet.

Was this page helpful?
0 / 5 - 0 ratings