Skip to content

Commit

Permalink
Add missing groupId inside list glossaries/projects (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhoko authored Apr 26, 2023
1 parent 0f32bee commit 2da1561
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
6 changes: 5 additions & 1 deletion crowdin_api/api_resources/glossaries/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def get_glossaries_path(self, glossaryId: Optional[int] = None):

def list_glossaries(
self,
groupId: Optional[int] = None,
page: Optional[int] = None,
offset: Optional[int] = None,
limit: Optional[int] = None,
Expand All @@ -49,10 +50,13 @@ def list_glossaries(
https://developer.crowdin.com/api/v2/#operation/api.glossaries.getMany
"""

params = {"groupId": groupId}
params.update(self.get_page_params(page=page, offset=offset, limit=limit))

return self._get_entire_data(
method="get",
path=self.get_glossaries_path(),
params=self.get_page_params(page=page, offset=offset, limit=limit),
params=params,
)

def add_glossary(self, name: str, languageId: str):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,38 @@ def test_get_screenshots_path(self, in_params, path, base_absolut_url):
resource = self.get_resource(base_absolut_url)
assert resource.get_glossaries_path(**in_params) == path

@pytest.mark.parametrize(
"incoming_data, request_params",
(
(
{},
{
"groupId": None,
"offset": 0,
"limit": 25,
},
),
(
{
"groupId": 1,
},
{
"groupId": 1,
"offset": 0,
"limit": 25,
},
),
),
)
@mock.patch("crowdin_api.requester.APIRequester.request")
def test_list_glossaries(self, m_request, base_absolut_url):
def test_list_glossaries(self, m_request, incoming_data, request_params, base_absolut_url):
m_request.return_value = "response"

resource = self.get_resource(base_absolut_url)
assert resource.list_glossaries() == "response"
assert resource.list_glossaries(**incoming_data) == "response"
m_request.assert_called_once_with(
method="get",
params=resource.get_page_params(),
params=request_params,
path=resource.get_glossaries_path(),
)

Expand Down
3 changes: 2 additions & 1 deletion crowdin_api/api_resources/projects/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def list_projects(
page: Optional[int] = None,
offset: Optional[int] = None,
limit: Optional[int] = None,
groupId: Optional[int] = None,
userId: Optional[Union[int, str]] = None,
hasManagerAccess: Optional[HasManagerAccess] = None,
):
Expand All @@ -56,7 +57,7 @@ def list_projects(
https://developer.crowdin.com/api/v2/#operation/api.projects.getMany
"""

params = {"userId": userId, "hasManagerAccess": hasManagerAccess}
params = {"userId": userId, "hasManagerAccess": hasManagerAccess, "groupId": groupId}
params.update(self.get_page_params(page=page, offset=offset, limit=limit))

return self._get_entire_data(method="get", path=self.get_projects_path(), params=params)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ def test_get_projects_path(self, projectId, path, base_absolut_url):
"offset": 0,
"limit": 10,
"userId": 1,
"groupId": 1,
"hasManagerAccess": HasManagerAccess.TRUE,
},
{
"offset": 0,
"limit": 10,
"userId": 1,
"groupId": 1,
"hasManagerAccess": HasManagerAccess.TRUE,
},
),
Expand All @@ -57,6 +59,7 @@ def test_get_projects_path(self, projectId, path, base_absolut_url):
"offset": 0,
"limit": 10,
"userId": None,
"groupId": None,
"hasManagerAccess": None,
},
),
Expand Down

0 comments on commit 2da1561

Please sign in to comment.