From 163bf425e794f8451cb5b169cb345e2ae625bff4 Mon Sep 17 00:00:00 2001 From: Gavin Ching Date: Tue, 23 Jun 2015 02:16:13 -0700 Subject: [PATCH] Add in bulk_delete to Items with test --- pypodio2/areas.py | 20 ++++++++++++++++---- tests/test_areas_item.py | 12 ++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/pypodio2/areas.py b/pypodio2/areas.py index 7eb9aec..2aa4c0e 100644 --- a/pypodio2/areas.py +++ b/pypodio2/areas.py @@ -84,7 +84,7 @@ class Item(Area): def find(self, item_id, basic=False, **kwargs): """ Get item - + :param item_id: Item ID :type item_id: int :return: Item info @@ -131,7 +131,7 @@ def update(self, item_id, attributes, silent=False, hook=True): """ Updates the item using the supplied attributes. If 'silent' is true, Podio will send no notifications to subscribed users and not post updates to the stream. - + Important: webhooks will still be called. """ if not isinstance(attributes, dict): @@ -148,6 +148,18 @@ def delete(self, item_id, silent=False, hook=True): hook=hook)), handler=lambda x, y: None) + def bulk_delete(self, app_id, attributes, silent=False): + if not isinstance(attributes, dict): + raise TypeError('Must be of type dict') + attributes = json.dumps(attributes) + + return self.transport.POST(body=attributes, + type='application/json', + url='/item/app/%d/delete/%s' % (app_id, + self.get_options(silent=silent))) + + + class Application(Area): def activate(self, app_id): @@ -249,7 +261,7 @@ def get(self, **kwargs): def delete(self, task_id): """ Deletes the app with the given id. - + :param task_id: Task ID :type task_id: str or int """ @@ -345,7 +357,7 @@ def find_all_for_org(self, org_id): def create(self, attributes): """ Create a new space - + :param attributes: Refer to API. Pass in argument as dictionary :type attributes: dict :return: Details of newly created space diff --git a/tests/test_areas_item.py b/tests/test_areas_item.py index 12e79e5..43cef3b 100644 --- a/tests/test_areas_item.py +++ b/tests/test_areas_item.py @@ -138,3 +138,15 @@ def test_delete(): 'DELETE', body=None, headers={}) + +def test_bulk_delete(): + app_id = 1 + attributes = { 'item_ids': [1,2,3] } + + client, check_assertions = check_client_method() + result = client.Item.bulk_delete(app_id, attributes) + check_assertions(result, + 'POST', + '/item/app/%s/delete/' % app_id, + json.dumps(attributes), + {'content-type': 'application/json'})