def test_delete_object_http_error(self): """Test whether an exception is thrown when the HTTP error is not 404""" obj_data = read_file('data/object_index-pattern') httpretty.register_uri(httpretty.DELETE, OBJECT_URL, body=obj_data, status=500) client = SavedObjects(KIBANA_URL) with self.assertRaises(requests.exceptions.HTTPError): _ = client.delete_object(OBJECT_TYPE, OBJECT_ID)
def test_delete_object(self): """Test the method delete_object""" httpretty.register_uri(httpretty.DELETE, OBJECT_URL, body="{}", status=200) client = SavedObjects(KIBANA_URL) with self.assertLogs(logger, level='INFO') as cm: _ = client.delete_object(OBJECT_TYPE, OBJECT_ID) self.assertEqual( cm.output[0], 'INFO:archimedes.clients.saved_objects:' 'Object ' + OBJECT_TYPE + ' with id ' + OBJECT_ID + ' deleted')
def test_delete_object_not_found(self): """Test whether a warning is logged when the object is not found""" obj_data = read_file('data/object_index-pattern') httpretty.register_uri(httpretty.DELETE, OBJECT_URL, body=obj_data, status=404) client = SavedObjects(KIBANA_URL) with self.assertLogs(logger, level='WARNING') as cm: obj = client.delete_object(OBJECT_TYPE, OBJECT_ID) self.assertEqual( cm.output[0], 'WARNING:archimedes.clients.saved_objects:' 'No ' + OBJECT_TYPE + ' found with id: ' + OBJECT_ID) self.assertIsNone(obj)