Skip to content

Commit 9bfe556

Browse files
authored
feat: mark exportMode and fileIds as deprecated in add_distribution() (#244)
1 parent 63114e5 commit 9bfe556

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

crowdin_api/api_resources/distributions/resource.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import warnings
12
from typing import Iterable, Optional
23

34
from crowdin_api.api_resources.abstract.resources import BaseResource
@@ -46,7 +47,7 @@ def add_distribution(
4647
projectId: Optional[int] = None,
4748
fileIds: Optional[Iterable[int]] = None,
4849
bundleIds: Optional[Iterable[int]] = None,
49-
exportMode: Optional[ExportMode] = ExportMode.DEFAULT,
50+
exportMode: Optional[ExportMode] = None,
5051
):
5152
"""
5253
Add Distribution.
@@ -57,6 +58,18 @@ def add_distribution(
5758

5859
projectId = projectId or self.get_project_id()
5960

61+
if exportMode is not None:
62+
warnings.warn(
63+
"`exportMode` is deprecated, omit this parameter to use the API default behavior",
64+
DeprecationWarning,
65+
)
66+
67+
if fileIds is not None:
68+
warnings.warn(
69+
"`fileIds` is deprecated, use `bundleIds` instead",
70+
DeprecationWarning,
71+
)
72+
6073
return self.requester.request(
6174
method="post",
6275
path=self.get_distributions_path(projectId=projectId),

crowdin_api/api_resources/distributions/tests/test_distributions_resources.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def test_list_distributions(self, m_request, base_absolut_url):
5656
"name": "test",
5757
"fileIds": [1, 2, 3],
5858
"bundleIds": None,
59-
"exportMode": ExportMode.DEFAULT
59+
"exportMode": None
6060
},
6161
),
6262
(
@@ -79,13 +79,30 @@ def test_list_distributions(self, m_request, base_absolut_url):
7979
def test_add_distribution(self, m_request, incoming_data, request_data, base_absolut_url):
8080
m_request.return_value = "response"
8181
resource = self.get_resource(base_absolut_url)
82-
assert resource.add_distribution(projectId=1, **incoming_data) == "response"
82+
with pytest.warns(DeprecationWarning):
83+
assert resource.add_distribution(projectId=1, **incoming_data) == "response"
8384
m_request.assert_called_once_with(
8485
method="post",
8586
path=resource.get_distributions_path(projectId=1),
8687
request_data=request_data,
8788
)
8889

90+
@mock.patch("crowdin_api.requester.APIRequester.request")
91+
def test_add_distribution_no_deprecated_params(self, m_request, base_absolut_url):
92+
m_request.return_value = "response"
93+
resource = self.get_resource(base_absolut_url)
94+
assert resource.add_distribution(projectId=1, name="test", bundleIds=[1]) == "response"
95+
m_request.assert_called_once_with(
96+
method="post",
97+
path=resource.get_distributions_path(projectId=1),
98+
request_data={
99+
"exportMode": None,
100+
"name": "test",
101+
"fileIds": None,
102+
"bundleIds": [1],
103+
},
104+
)
105+
89106
@mock.patch("crowdin_api.requester.APIRequester.request")
90107
def test_get_distribution(self, m_request, base_absolut_url):
91108
m_request.return_value = "response"

0 commit comments

Comments
 (0)