From ce99a87ca91f07190b46a9e0b0a66b680402db27 Mon Sep 17 00:00:00 2001 From: Patrick Huck Date: Fri, 12 May 2023 11:16:24 -0700 Subject: [PATCH] client: fix delete_project --- mpcontribs-client/mpcontribs/client/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mpcontribs-client/mpcontribs/client/__init__.py b/mpcontribs-client/mpcontribs/client/__init__.py index c916fd35d..cdaa0a749 100644 --- a/mpcontribs-client/mpcontribs/client/__init__.py +++ b/mpcontribs-client/mpcontribs/client/__init__.py @@ -989,8 +989,11 @@ def delete_project(self, name: str = None): if not name: raise MPContribsClientError("initialize client with project or set `name` argument!") + if not self.get_totals(query={"name": name}, resource="projects")[0]: + raise MPContribsClientError(f"Project `{name}` doesn't exist!") + resp = self.projects.deleteProjectByName(pk=name).result() - if "error" in resp: + if resp and "error" in resp: raise MPContribsClientError(resp["error"]) def get_contribution(self, cid: str) -> Type[Dict]: