def get_components(self, endpoint): json_str = CachetApiV1.get_components(endpoint) if json_str == None: raise Exception(CONST_ERROR_MESSAGE_CACHET_API_V1) json_object = json.loads(json_str) components_json_array = json_object[CONST_DATA_JSON_ATTR] components = [] for component_json in components_json_array: name = component_json[CONST_NAME_JSON_ATTR] id = component_json[CONST_ID_JSON_ATTR] components.append(Component(id=id, name=name)) return components
def test_get_components_error(self): response = CachetApiV1.get_components("http://wrong_url") self.assertIsNone(response)