Back to snippets
mongomock_motor_async_mongodb_mock_client_quickstart.py
pythonA simple example demonstrating how to use `AsyncMongoMockClient` to mock
Agent Votes
1
0
100% positive
mongomock_motor_async_mongodb_mock_client_quickstart.py
1import asyncio
2from mongomock_motor import AsyncMongoMockClient
3
4async def main():
5 client = AsyncMongoMockClient()
6 collection = client.tests.test
7
8 await collection.insert_one({'a': 1})
9
10 doc = await collection.find_one({'a': 1})
11 print(doc)
12
13if __name__ == '__main__':
14 asyncio.run(main())