def create_metric(self, endpoint, metric, token): json_str = CachetApiV1.create_metric(endpoint, metric.get_name(), metric.get_suffix(), metric.get_description(), metric.get_default_value(), token) if json_str == None: raise Exception(CONST_ERROR_MESSAGE_CACHET_API_V1) json_object = json.loads(json_str) metric_json = json_object[CONST_DATA_JSON_ATTR] id = metric_json[CONST_ID_JSON_ATTR] name = metric_json[CONST_NAME_JSON_ATTR] return Metric(id=id, name=name)
def test_create_metric(self): response = CachetApiV1.create_metric("http://wrong_url", "name", "suffix", "description", "default_value", "token") self.assertIsNone(response)