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

feat(screenshots): added parameter and deprecation warning #173

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
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
9 changes: 8 additions & 1 deletion crowdin_api/api_resources/screenshots/resource.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Iterable, Optional

import warnings
from crowdin_api.api_resources.abstract.resources import BaseResource
from crowdin_api.api_resources.screenshots.types import (
AddTagRequest,
Expand Down Expand Up @@ -30,8 +31,10 @@ def get_screenshots_path(self, projectId: int, screenshotId: Optional[int] = Non

def list_screenshots(
self,
orderBy: Optional[str] = None,
projectId: Optional[int] = None,
stringId: Optional[int] = None,
stringIds: Optional[Iterable[int]] = None,
labelIds: Optional[Iterable[int]] = None,
excludeLabelIds: Optional[Iterable[int]] = None,
page: Optional[int] = None,
Expand All @@ -47,7 +50,11 @@ def list_screenshots(

projectId = projectId or self.get_project_id()

params = {"stringId": stringId, "labelIds": labelIds, "excludeLabelIds": excludeLabelIds}
if stringId:
warnings.warn("`stringId` is deprecated, use `stringIds` instead", category=DeprecationWarning)
stringIds = [stringId]

params = {"orderBy": orderBy, "stringIds": stringIds, "labelIds": labelIds, "excludeLabelIds": excludeLabelIds}
params.update(self.get_page_params(page=page, offset=offset, limit=limit))

return self._get_entire_data(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,21 @@ def test_get_screenshots_path(self, in_params, path, base_absolut_url):
def test_list_screenshots(self, m_request, base_absolut_url):
m_request.return_value = "response"
resource = self.get_resource(base_absolut_url)
assert resource.list_screenshots(projectId=1, **{"offset": 0, "limit": 10}) == "response"
assert (
resource.list_screenshots(projectId=1, **{"offset": 0, "limit": 10})
== "response"
)
m_request.assert_called_once_with(
method="get",
path=resource.get_screenshots_path(projectId=1),
params={'stringId': None, 'labelIds': None, 'excludeLabelIds': None, 'offset': 0, 'limit': 10},
params={
"orderBy": None,
"stringIds": None,
"labelIds": None,
"excludeLabelIds": None,
"offset": 0,
"limit": 10,
},
)

@pytest.mark.parametrize(
Expand Down