Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
Better existence check for project. More strings in tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
why-not-try-calmer committed Feb 18, 2023
1 parent 94f6cc9 commit 1328ff6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 9 additions & 3 deletions pytransifex/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,15 @@ def create_language(
@ensure_login
def project_exists(self, project_slug: str) -> bool:
"""Check if the project exists in the remote Transifex repository"""
if self.projects and self.projects.get(slug=project_slug):
return True
return False
try:
if not self.projects:
return False
elif self.projects.get(slug=project_slug):
return True
else:
return False
except DoesNotExist:
return False

@ensure_login
def ping(self) -> bool:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ def test4_create_resource(self):
project_slug=self.project_slug,
resource_name=self.resource_name,
resource_slug=self.resource_slug,
path_to_file=self.path_to_file,
path_to_file=str(self.path_to_file),
)
assert True

def test5_update_source_translation(self):
self.tx.update_source_translation(
project_slug=self.project_slug,
path_to_file=self.path_to_file,
path_to_file=str(self.path_to_file),
resource_slug=self.resource_slug,
)
assert True
Expand All @@ -81,7 +81,7 @@ def test8_get_translation(self):
project_slug=self.project_slug,
resource_slug=self.resource_slug,
language_code="fr_CH",
path_to_file=self.output_dir,
path_to_file=str(self.output_dir),
)
assert Path.exists(Path.joinpath(self.output_dir, self.resource_slug))

Expand Down

0 comments on commit 1328ff6

Please sign in to comment.