'Test update operations.'

def test_update(self):

    self.conn.test.test.insert_one({'a': 0})
    assert_soon((lambda : (sum((1 for _ in self._search())) == 1)))
    def check_update(update_spec):
        updated = self.conn.test.command(SON([('findAndModify', 'test'), ('query', {'a': 0}), ('update', update_spec), ('new', True)]))['value']
        def update_worked():
            replicated = self.mongo_doc.mongo.test.test.find_one({'a': 0})
            return (replicated == updated)
        assert_soon(update_worked)
    check_update({'$set': {'b': [{'c': 10}, {'d': 11}]}})
    check_update({'$set': {'b.10.c': 42}})
    check_update({'$unset': {'b.10': True}})
    check_update({'$unset': {'not-present': True}})
    check_update({'$inc': {'b.0.c': 1}})
    check_update({'$inc': {'b.1.f': 12}})
    check_update({'$push': {'b': {'e': 12}}})
    check_update({'$set': {'b.0': {'e': 4}}})
    check_update({'$set': {'b': {'0': {'c': 100}}}})
    check_update({'a': 0, 'b': {'1': {'d': 10000}}})
