From e665b201235c1ab44f113ccd9a3b27a4b5fcb1fc Mon Sep 17 00:00:00 2001 From: Max Inno Date: Mon, 3 Aug 2026 07:03:54 +0300 Subject: [PATCH] feat(bundles): add request body and export settings to Export Bundle --- crowdin_api/api_resources/bundles/resource.py | 20 ++++++++- .../bundles/tests/test_bundles_resources.py | 42 +++++++++++++++++-- 2 files changed, 58 insertions(+), 4 deletions(-) diff --git a/crowdin_api/api_resources/bundles/resource.py b/crowdin_api/api_resources/bundles/resource.py index fe305e1..ae6c860 100644 --- a/crowdin_api/api_resources/bundles/resource.py +++ b/crowdin_api/api_resources/bundles/resource.py @@ -172,7 +172,17 @@ def download_bundle( path=f"{self.get_bundles_exports_path(projectId=projectId, bundleId=bundleId, exportId=exportId)}/download", ) - def export_bundle(self, bundleId: int, projectId: Optional[int] = None): + def export_bundle( + self, + bundleId: int, + projectId: Optional[int] = None, + targetLanguageIds: Optional[Iterable[str]] = None, + skipUntranslatedStrings: Optional[bool] = None, + skipUntranslatedFiles: Optional[bool] = None, + exportApprovedOnly: Optional[bool] = None, + exportWithMinApprovalsCount: Optional[int] = None, + exportStringsThatPassedWorkflow: Optional[bool] = None, + ): """ Export bundle. @@ -188,6 +198,14 @@ def export_bundle(self, bundleId: int, projectId: Optional[int] = None): return self.requester.request( method="post", path=self.get_bundles_exports_path(projectId=projectId, bundleId=bundleId), + request_data={ + "targetLanguageIds": targetLanguageIds, + "skipUntranslatedStrings": skipUntranslatedStrings, + "skipUntranslatedFiles": skipUntranslatedFiles, + "exportApprovedOnly": exportApprovedOnly, + "exportWithMinApprovalsCount": exportWithMinApprovalsCount, + "exportStringsThatPassedWorkflow": exportStringsThatPassedWorkflow, + }, ) def check_bundle_export_status( diff --git a/crowdin_api/api_resources/bundles/tests/test_bundles_resources.py b/crowdin_api/api_resources/bundles/tests/test_bundles_resources.py index 5b56a20..9fbecee 100644 --- a/crowdin_api/api_resources/bundles/tests/test_bundles_resources.py +++ b/crowdin_api/api_resources/bundles/tests/test_bundles_resources.py @@ -195,14 +195,50 @@ def test_download_bundle(self, m_request, base_absolut_url): method="get", path=f"{resource.get_bundles_exports_path(projectId=1, bundleId=1, exportId='1')}/download" ) + @pytest.mark.parametrize( + "incoming_data, request_data", + ( + ( + {}, + { + "targetLanguageIds": None, + "skipUntranslatedStrings": None, + "skipUntranslatedFiles": None, + "exportApprovedOnly": None, + "exportWithMinApprovalsCount": None, + "exportStringsThatPassedWorkflow": None, + }, + ), + ( + { + "targetLanguageIds": ["uk", "de"], + "skipUntranslatedStrings": True, + "skipUntranslatedFiles": False, + "exportApprovedOnly": True, + "exportWithMinApprovalsCount": 2, + "exportStringsThatPassedWorkflow": True, + }, + { + "targetLanguageIds": ["uk", "de"], + "skipUntranslatedStrings": True, + "skipUntranslatedFiles": False, + "exportApprovedOnly": True, + "exportWithMinApprovalsCount": 2, + "exportStringsThatPassedWorkflow": True, + }, + ), + ), + ) @mock.patch("crowdin_api.requester.APIRequester.request") - def test_export_bundle(self, m_request, base_absolut_url): + def test_export_bundle(self, m_request, incoming_data, request_data, base_absolut_url): m_request.return_value = "response" resource = self.get_resource(base_absolut_url) - assert resource.export_bundle(projectId=1, bundleId=1) == "response" + assert resource.export_bundle(projectId=1, bundleId=1, **incoming_data) == "response" m_request.assert_called_once_with( - method="post", path=resource.get_bundles_exports_path(projectId=1, bundleId=1) + method="post", + path=resource.get_bundles_exports_path(projectId=1, bundleId=1), + request_data=request_data, ) @mock.patch("crowdin_api.requester.APIRequester.request")