Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

masquerade and more async methods #2

Merged
merged 5 commits into from Nov 17, 2021
Merged

masquerade and more async methods #2

merged 5 commits into from Nov 17, 2021

Conversation

michaelkryukov
Copy link
Owner

Changes:

  • Added masquerading mock classes as motor's original, so checks like isinstance(collection, AsyncIOMotorCollection) won't fail. It's possible there will still be issues if you expected to use tornado classes instead of asyncio, but I will wait for actual cases to somehow solve this.
  • Added some async methods for collection.
  • Added test that checks basic compatibility with beanie ODM.

Notes:

@tclasen
Copy link
Contributor

tclasen commented Nov 17, 2021

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
Copy link
Contributor

tclasen commented Nov 17, 2021

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
Copy link
Owner Author

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
Copy link
Contributor

tclasen commented Nov 17, 2021

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

@michaelkryukov michaelkryukov merged commit 2a3c9d8 into main Nov 17, 2021
@michaelkryukov michaelkryukov deleted the masquerade branch November 17, 2021 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants