def test_find_one(self, test_db):
_id = (await test_db.test.insert_one({'hello': 'world', 'foo': 'bar'})).inserted_id
assert 'world' == (await test_db.test.find_one())['hello']
assert await test_db.test.find_one(_id) == await test_db.test.find_one()
assert await test_db.test.find_one(None) == await test_db.test.find_one()
assert await test_db.test.find_one({}) == await test_db.test.find_one()
assert await test_db.test.find_one({'hello': 'world'}) == await test_db.test.find_one()
assert 'hello' in await test_db.test.find_one(projection=['hello'])
assert 'hello' not in await test_db.test.find_one(projection=['foo'])
assert ['_id'] == list(await test_db.test.find_one(projection=[]))
assert await test_db.test.find_one({'hello': 'foo'}) is None
assert await test_db.test.find_one(ObjectId()) is None
评论列表
文章目录