

def check_collections(self):
    '\n        Check collections in all databases\n        '
    result = {
        'state': 'OK',
        'messages': {
            'info': [],
            'error': [],
            'warn': [],
        },
    }
    databases = result.connection.database_names()
    if (not databases):
        result['state'] = 'WARN'
        result['messages']['warn'].append('No databases found')
    for database in databases:
        db = self.connection[database]
        collections = db.collection_names()
        if (self.empty_collections and (not collections)):
            if (database == 'local'):
                if (result['state'] not in ['ERROR', 'WARN']):
                    result['state'] = 'OK'
                result['messages']['info'].append(('Database %s: no collections found but it is expected' % database))
                continue
            else:
                if (result['state'] != 'ERROR'):
                    result['state'] = 'WARN'
                result['messages']['warn'].append(('Database %s: no collections found, empty database' % database))
                continue
        if self.validate_collections:
            for collection in collections:
                validation = db.validate_collection(collection)
                if validation['valid']:
                    result['messages']['info'].append(('Database %s: collection %s is valid' % (database, collection)))
                    if (result['state'] not in ['ERROR', 'WARN']):
                        result['state'] = 'OK'
                else:
                    for e in validation['errors']:
                        result['messages']['error'].append(('Database %s: %s' % (database, e)))
                    result['state'] = 'ERROR'
        else:
            if (result['state'] not in ['ERROR', 'WARN']):
                result['state'] = 'OK'
            result['messages']['info'].append(('Database %s: %d collections found' % (database, len(collections))))
    return result

dataset/ETHPy150Open gooddata/smoker/smoker/server/plugins/mongo.py Plugin.check_collections/VarMisuse@50/79 `self`->`result`