Mocking motor client in tests

Hello, everyone!
I’m trying to find ways of patching motor client for testing purposes. I want to mock database to test code which make database requests.
I was wondering If anyone has some links, tips or best practices. Unfortunately can’t find anything myself

Unfortunately, I am unable to point you to any examples of mocking Motor’s database objects. Our test suite almost always uses a live Database object. If you are just trying to test if your application code correctly uses the DB object, then you can use unittest’s Mock/MagicMock ( class to replace the APIs you are interested in and run assertions on their usage.

1 Like