This repository has been archived by the owner on Dec 2, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added test for public transifex repositories
- Loading branch information
1 parent
a4dff86
commit 24820c5
Showing
6 changed files
with
79 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
organization_slug = "test_pytransifex" | ||
project_slug = "test_project_pytransifex" | ||
project_name = "Python Transifex API testing" | ||
repository_url = "https://github.com/opengisch/pytransifex" | ||
resource_slug = "test_resource_fr" | ||
resource_name = "Test Resource FR" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
organization_slug = "test_pytransifex" | ||
project_slug = "test_project_pytransifex_public" | ||
project_name = "Python Transifex API testing (public)" | ||
resource_slug = "test_resource_fr" | ||
resource_name = "Test Resource FR" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import unittest | ||
from os import remove | ||
from pathlib import Path | ||
|
||
from pytransifex.api import Transifex | ||
from tests import logging, test_config_public | ||
|
||
|
||
class TestCli(unittest.TestCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
client = Transifex(defer_login=True) | ||
assert client | ||
|
||
cls.path_to_input_dir = Path.cwd().joinpath("tests", "data", "resources") | ||
cls.path_to_file = cls.path_to_input_dir.joinpath("test_resource_fr.po") | ||
cls.output_dir = Path.cwd().joinpath("tests", "output") | ||
|
||
cls.tx = client | ||
cls.project_slug = test_config_public["project_slug"] | ||
cls.project_name = test_config_public["project_name"] | ||
cls.resource_slug = test_config_public["resource_slug"] | ||
cls.resource_name = test_config_public["resource_name"] | ||
repository_url = test_config_public["repository_url"] | ||
|
||
if missing := next( | ||
filter(lambda p: not p.exists(), [cls.path_to_file, cls.path_to_input_dir]), | ||
None, | ||
): | ||
raise ValueError( | ||
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("Creating a brand new project") | ||
cls.tx.create_project( | ||
project_name=cls.project_name, | ||
project_slug=cls.project_slug, | ||
private=False, | ||
repository_url=repository_url, | ||
) | ||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
if Path.exists(cls.output_dir): | ||
remove(cls.output_dir) | ||
|
||
def test1_project_exists(self): | ||
verdict = self.tx.project_exists(project_slug=self.project_slug) | ||
assert verdict | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |