test_collection.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:aiomongo 作者: ZeoAlliance 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号