michaelkryukov / mongomock_motor

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

It is impossible to use database methods #12

Closed ArchiDevil closed 2 years ago

ArchiDevil commented 2 years ago

Hi, thank you for a great project!

We tried to use it in a real project and found out that it is impossible to use database methods due to a wrapper that thinks that every attribute is a collection name. Is it difficult to implement methods support in Database wrapper? We are trying to use list_collection_names method to access collections without knowing their names.

michaelkryukov commented 2 years ago

Hi, I've implemented this as part of #13. Can you confirm that current main works for you (and open issue again if something fails)?

ArchiDevil commented 2 years ago

I'm going to try it today, thank you for you work.

One more question, I haven't created an issue for that, but it may be a problem. We also encountered that some methods (for example method to_list from a result of collection.find(...)) are requiring named arguments, but you wrapper allows me to call them without any one. This leads to passed tests in the testing environment, but when I use motor it fails.

Our DB layer is small and this is not a big issue for now, but it may be a good point for future improvements.

ArchiDevil commented 2 years ago

@michaelkryukov, it seems to be working now, thank you again for the quick fix.

Any ETA when it is coming to PyPI?

michaelkryukov commented 2 years ago

As for the to_list problem, looking at the motor source, it doesn't require a named argument. This may have been required for earlier versions. I'm not sure. The new release will be available today or tomorrow

ArchiDevil commented 2 years ago

Sorry, I said named argument, but meant a positional one. Currently it is possible to use your wrapper without argument at all, but motor requires at least None for length here.