

def test__insert_object_id_as_dict(self):
    self.cmp.do.remove()
    doc_ids = [{
        'A': 1,
    }, {
        'A': [1, 2, 3],
    }, {
        'A': {
            'sub': {
                'subsub': 3,
            },
        },
    }]
    for doc_id in doc_ids:
        _id = self.cmp.do.insert({
            '_id': doc_id,
            'a': 1,
        })
        self.assertEqual(_id['fake'], _id['real'])
        self.assertEqual(_id['fake'], doc_id)
        self.assertEqual(_id['real'], doc_id)
        self.assertEqual(type(_id['fake']), type(_id['real']))
        self.cmp.compare.find({
            '_id': doc_id,
        })
        docs = self.cmp.compare.find_one({
            '_id': doc_id,
        })
        self.assertEqual(docs['fake']['_id'], doc_id)
        self.assertEqual(docs['real']['_id'], doc_id)
        self.cmp.do.remove({
            '_id': doc_id,
        })

dataset/ETHPy150Open vmalloc/mongomock/tests/test__mongomock.py MongoClientCollectionTest.test__insert_object_id_as_dict/original