def get_metrics(self, endpoint):
		json_str = CachetApiV1.get_metrics(endpoint)
		if json_str == None:
			raise Exception(CONST_ERROR_MESSAGE_CACHET_API_V1)

		json_object = json.loads(json_str)
		metrics_json_array = json_object[CONST_DATA_JSON_ATTR]
		metrics = []
		for metric_json in metrics_json_array:
		    name = metric_json[CONST_NAME_JSON_ATTR]
		    id = metric_json[CONST_ID_JSON_ATTR]
		    metrics.append(Metric(id=id, name=name))
		return metrics			
Exemple #2
0
 def test_get_metrics(self):
     response = CachetApiV1.get_metrics("http://wrong_url")
     self.assertIsNone(response)