michaelkryukov / mongomock_motor

Library for mocking AsyncIOMotorClient built on top of mongomock.
MIT License
94 stars 23 forks source link

feat: Add patch to provide error details for replace_one() #31

Closed chenjr0719 closed 1 year ago

chenjr0719 commented 1 year ago

Hi there, thanks for creating this fantastic package. It saves my life to test with motor.

In my use case, I also need the error details of DuplicateKeyError when using replace_one(). So I made this PR to fit my requirement. I think someone else might need this feature as well. Please let me know if the test cases or implementation should be modified. 👍

michaelkryukov commented 1 year ago

Hey. I looked into the issue and found out that only two of mongomock's methods raise DuplicateKeyError – _insert and _ensure_uniques. So I've created MR (https://github.com/michaelkryukov/mongomock_motor/pull/32) where I patch _insert and _ensure_uniques (with tests from this MR). If it works for you, I can close this one and merge #32