From 75c149c4014d1e296f059a41f1dd297d0f96ae8e Mon Sep 17 00:00:00 2001 From: Michael Harbarth Date: Tue, 29 Oct 2024 17:02:02 +0100 Subject: [PATCH] fix: delete workitems via status --- polarion_rest_api_client/clients/base_classes.py | 8 +++++++- polarion_rest_api_client/clients/work_items.py | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/polarion_rest_api_client/clients/base_classes.py b/polarion_rest_api_client/clients/base_classes.py index 2f79f51..bb74316 100644 --- a/polarion_rest_api_client/clients/base_classes.py +++ b/polarion_rest_api_client/clients/base_classes.py @@ -250,6 +250,8 @@ class StatusItemClient(UpdatableItemsClient, t.Generic[ST], abc.ABC): them. This status has to be provided on initialization. """ + item_cls: type[ST] + def __init__( self, project_id: str, @@ -266,6 +268,10 @@ def delete(self, items: ST | list[ST]): else: if not isinstance(items, list): items = [items] + delete_items: list[ST] = [] for item in items: item.status = self.delete_status - self.update(items) + delete_items.append( + self.item_cls(id=item.id, status=self.delete_status) + ) + self.update(delete_items) diff --git a/polarion_rest_api_client/clients/work_items.py b/polarion_rest_api_client/clients/work_items.py index b30f503..57b08c6 100644 --- a/polarion_rest_api_client/clients/work_items.py +++ b/polarion_rest_api_client/clients/work_items.py @@ -49,6 +49,7 @@ def __init__( project_id, client ) self.links = work_item_links.WorkItemLinks(project_id, client) + self.item_cls = dm.WorkItem def _update(self, to_update: list[dm.WorkItem] | dm.WorkItem): assert not isinstance(to_update, list), "Expected only one item"