diff --git a/pytransifex/api.py b/pytransifex/api.py index 05557a9..4dbc6b0 100644 --- a/pytransifex/api.py +++ b/pytransifex/api.py @@ -78,6 +78,12 @@ def create_project( else: logging.error(f"Unable to create project; API replied with {error}") + @ensure_login + def delete_project(self, project_slug: str): + if project := self.get_project(project_slug=project_slug): + project.delete() + logging.info(f"Deleted project: {project_slug}") + @ensure_login def get_project(self, project_slug: str) -> None | Resource: """Fetches the project matching the given slug""" diff --git a/tests/test_api.py b/tests/test_api.py index ce9a24e..21d3db1 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -29,9 +29,8 @@ def setUpClass(cls): f"Unable to complete test with broken tests inputs. Found missing: {missing}" ) - if project := cls.tx.get_project(project_slug=cls.project_slug): - logging.info("Found old project, removing.") - project.delete() + logging.info("Deleting test project if it already exists") + cls.tx.delete_project(project_slug=cls.project_slug) logging.info("Creating a brand new project") cls.tx.create_project(