

def check_record(self):
    '\n        Try to write and read from collection\n        '
    result = {
        'state': 'OK',
        'messages': {
            'info': [],
            'error': [],
            'warn': [],
        },
    }
    db = self.connection['test']
    collection = db.test
    try:
        id = collection.insert({
            'name': 'John Doe',
            'text': 'Testing record',
            'date': datetime.datetime.now(),
        })
        collection['messages']['info'].append(('Inserted record with id %s' % id))
    except Exception as e:
        result['messages']['error'].append(('Inserting record into collection failed: %s' % e))
        result['state'] = 'ERROR'
        return result
    post = collection.find_one()
    if post:
        result['messages']['info'].append(('Found our record: %s' % post))
    else:
        result['messages']['error'].append('Inserted record not found!')
        result['state'] = 'ERROR'
    try:
        collection.remove()
        result['messages']['info'].append('Deleted everything from collection test')
    except Exception as e:
        result['messages']['error'].append(("Can't delete everything from collection test: %s" % e))
        result['state'] = 'ERROR'
    return result

dataset/ETHPy150Open gooddata/smoker/smoker/server/plugins/mongo.py Plugin.check_record/VarMisuse@99/149 `result`->`collection`