def metricList(request): """ Returns a list of all registered metrics """ try: ret = map(lambda m: m.values, metrics.get_all()) except Exception, e: LOG.error(e) return jsonrpc.result_error('ServerError', { 'status': 'error', 'message': 'Unable to obtain metric list' })
def test_metric_get_all(self): """Check getting metrics from db""" data = { 'id': str(uuid.uuid4()), 'type': str(uuid.uuid4())[:10], 'formula': metrics.constants.FORMULA_UNIT, 'aggregate': 0L, } data1 = data.copy() data1['id'] = unicode(uuid.uuid4()) data1['formula'] = metrics.constants.FORMULA_TIME met = metrics.Metric(data) met1 = metrics.Metric(data1) with database.DBConnect() as db: db.insert('metrics', data) db.insert('metrics', data1) self.assertEquals(set(list(metrics.get_all())), set([met,met1]))