michaelkryukov / mongomock_motor

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

masquerade and more async methods #2

Closed michaelkryukov closed 2 years ago

michaelkryukov commented 2 years ago

Changes:

Notes:

tclasen commented 2 years ago

Hey again! Here is my example code base that prompted the previous PR if you want to test against this. If you look at the init_mongo function you can see I'm passing in an arg and a kwarg. If I remove those, your branch les me pass unit tests 100%. Could we also add something to consume excess *args and **kwargs when initializing the client?

https://github.com/tclasen/fastapiplayground

tclasen commented 2 years ago

And also, a HUGE thank you for even making this library. Unit testing async mongo has been such a pain for the longest time. Despite your repo only being a few days old, it is the most complete / working implementation on the market right now.

michaelkryukov commented 2 years ago

Pretty much all the credit goes to mongomock, they did most of the job 😄. Nice to see that I'm not the only one who needed a viable mock for async mongo too. I added *args, **kwargs to AsyncMongoMockClient's __init__. This should fix mocking with AsyncMongoMockClient.

tclasen commented 2 years ago

I just confirmed your newest commit passes all tests in my repo using Beanie.