Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: String Exporter Settings API #106

Merged
merged 4 commits into from
Sep 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 188 additions & 0 deletions crowdin_api/api_resources/projects/tests/test_projects_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,3 +535,191 @@ def test_edit_project_file_format_settings(self, m_request, base_absolut_url):
request_data=data,
path=resource.get_project_file_format_settings_path(projectId=1, fileFormatSettingsId=2),
)

@pytest.mark.parametrize(
"in_params, path",
(
({"projectId": 1}, "projects/1/strings-exporter-settings"),
({"projectId": 1, "systemStringExporterSettingsId": 2}, "projects/1/strings-exporter-settings/2"),
),
)
def test_get_strings_exporter_path(self, in_params, path, base_absolut_url):
resource = self.get_resource(base_absolut_url)
assert resource.get_strings_exporter_path(**in_params) == path

@mock.patch("crowdin_api.api_resources.abstract.resources.BaseResource._get_entire_data")
def test_list_project_strings_exporter_settings(self, m_request, base_absolut_url):
m_request.return_value = "response"

resource = self.get_resource(base_absolut_url)
assert resource.list_project_strings_exporter_settings(1) == "response"
m_request.assert_called_once_with(
method="get", path=resource.get_strings_exporter_path(1)
)

@pytest.mark.parametrize(
"in_params, request_data",
(
(
{
"format": "android",
"settings": {
"convertPlaceholders": True,
},
},
{
"format": "android",
"settings": {
"convertPlaceholders": True,
},
},
),
(
{
"format": "macosx",
"settings": {
"convertPlaceholders": True,
},
},
{
"format": "macosx",
"settings": {
"convertPlaceholders": True,
},
},
),
(
{
"format": "xliff",
"settings": {
"languagePaitMapping": {
"uk": "es",
"de": "en",
},
},
},
{
"format": "xliff",
"settings": {
"languagePaitMapping": {
"uk": "es",
"de": "en",
},
},
},
),
),
)
@mock.patch("crowdin_api.requester.APIRequester.request")
def test_add_project_strings_exporter_settings(self, m_request, in_params, request_data, base_absolut_url):
m_request.return_value = "response"

resource = self.get_resource(base_absolut_url)
assert resource.add_project_strings_exporter_settings(projectId=1, **in_params) == "response"
m_request.assert_called_once_with(
method="post",
path=resource.get_strings_exporter_path(projectId=1),
request_data=request_data
)

@mock.patch("crowdin_api.requester.APIRequester.request")
def test_get_project_strings_exporter_settings(self, m_request, base_absolut_url):
m_request.return_value = "response"

resource = self.get_resource(base_absolut_url)
assert resource.get_project_strings_exporter_settings(
projectId=1, systemStringExporterSettingsId=2
) == "response"

m_request.assert_called_once_with(
method="get",
path=resource.get_strings_exporter_path(
projectId=1, systemStringExporterSettingsId=2
),
)

@mock.patch("crowdin_api.requester.APIRequester.request")
def test_delete_project_strings_exporter_settings(self, m_request, base_absolut_url):
m_request.return_value = "response"

resource = self.get_resource(base_absolut_url)
assert resource.delete_project_strings_exporter_settings(
projectId=1, systemStringExporterSettingsId=2
) == "response"

m_request.assert_called_once_with(
method="delete",
path=resource.get_strings_exporter_path(
projectId=1, systemStringExporterSettingsId=2
),
)

@pytest.mark.parametrize(
"in_params, request_data",
(
(
{
"format": "android",
"settings": {
"convertPlaceholders": True,
},
},
{
"format": "android",
"settings": {
"convertPlaceholders": True,
},
},
),
(
{
"format": "macosx",
"settings": {
"convertPlaceholders": True,
},
},
{
"format": "macosx",
"settings": {
"convertPlaceholders": True,
},
},
),
(
{
"format": "xliff",
"settings": {
"languagePaitMapping": {
"uk": "es",
"de": "en",
},
},
},
{
"format": "xliff",
"settings": {
"languagePaitMapping": {
"uk": "es",
"de": "en",
},
},
},
),
),
)
@mock.patch("crowdin_api.requester.APIRequester.request")
def test_edit_project_strings_exporter_settings(self, m_request, in_params, request_data, base_absolut_url):
m_request.return_value = "response"

resource = self.get_resource(base_absolut_url)
assert resource.edit_project_strings_exporter_settings(
projectId=1,
systemStringExporterSettingsId=2,
**in_params,
) == "response"

m_request.assert_called_once_with(
method="patch",
path=resource.get_strings_exporter_path(projectId=1, systemStringExporterSettingsId=2),
request_data=request_data,
)