diff --git a/pytransifex/api.py b/pytransifex/api.py index 2cfe67d..1cfa5c5 100755 --- a/pytransifex/api.py +++ b/pytransifex/api.py @@ -156,6 +156,12 @@ def list_resources(self, project_slug) -> list: return json.loads(codecs.decode(response.content, 'utf-8')) + def delete_team(self, team_slug: str): + url = 'https://rest.api.transifex.com/projects/o:{o}:t:{t}'.format(o=self.organization, t=team_slug) + response = requests.delete(url, headers={'Content-Type': 'application/vnd.api+json','Authorization': 'Bearer {}'.format(self.api_key)}) + if response.status_code != requests.codes['OK']: + raise PyTransifexException(response) + def create_resource(self, project_slug, path_to_file, diff --git a/test/test_translation.py b/test/test_translation.py index c59faa4..ab7f6ff 100644 --- a/test/test_translation.py +++ b/test/test_translation.py @@ -12,7 +12,7 @@ def setUp(self): token = os.getenv('TX_TOKEN') assert token is not None self.t = Transifex(organization='pytransifex', api_token=token) - self.project_slug = 'pytransifex' + self.project_slug = 'pytransifex-test-project' self.project_name = 'PyTransifex Test project' self.source_lang = 'fr_FR' @@ -21,6 +21,10 @@ def tearDown(self): self.t.delete_project(self.project_slug) except PyTransifexException: pass + try: + self.t.delete_team('{}-team'.format(self.project_slug)) + except PyTransifexException: + pass def test_creation(self): self.tearDown()