From 7a1ba16f8af551bae5d68eac597f5af82ebd8f57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Luna?= Date: Fri, 29 Nov 2024 18:18:50 -0300 Subject: [PATCH] feat(api): Add croql parameter support to List Terms API Added support for filtering terms using CroQL query parameter in the List Terms API endpoint. This implementation includes: - Added croql parameter to list_terms method - Updated test suite with new test cases for CroQL filtering - Maintained compatibility with existing query parameters Related issue: #182 --- crowdin_api/api_resources/glossaries/resource.py | 2 ++ .../glossaries/tests/test_glossaries_resources.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/crowdin_api/api_resources/glossaries/resource.py b/crowdin_api/api_resources/glossaries/resource.py index 5d117ef..e7fd705 100644 --- a/crowdin_api/api_resources/glossaries/resource.py +++ b/crowdin_api/api_resources/glossaries/resource.py @@ -242,6 +242,7 @@ def list_terms( userId: Optional[int] = None, languageId: Optional[str] = None, conceptId: Optional[int] = None, + croql: Optional[str] = None, offset: Optional[int] = None, limit: Optional[int] = None, ): @@ -256,6 +257,7 @@ def list_terms( "userId": userId, "languageId": languageId, "conceptId": conceptId, + "croql": croql, } params.update(self.get_page_params(offset=offset, limit=limit)) diff --git a/crowdin_api/api_resources/glossaries/tests/test_glossaries_resources.py b/crowdin_api/api_resources/glossaries/tests/test_glossaries_resources.py index c67fd70..d418ac6 100644 --- a/crowdin_api/api_resources/glossaries/tests/test_glossaries_resources.py +++ b/crowdin_api/api_resources/glossaries/tests/test_glossaries_resources.py @@ -272,6 +272,7 @@ def test_get_terms_path(self, in_params, path, base_absolut_url): "userId": None, "languageId": None, "conceptId": None, + "croql": None, "offset": 0, "limit": 25, }, @@ -281,11 +282,13 @@ def test_get_terms_path(self, in_params, path, base_absolut_url): "userId": 1, "languageId": "ua", "conceptId": 2, + "croql": "status = 'preferred'", }, { "userId": 1, "languageId": "ua", "conceptId": 2, + "croql": "status = 'preferred'", "offset": 0, "limit": 25, }, @@ -295,7 +298,6 @@ def test_get_terms_path(self, in_params, path, base_absolut_url): @mock.patch("crowdin_api.requester.APIRequester.request") def test_list_terms(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_terms(glossaryId=1, **incoming_data) == "response" m_request.assert_called_once_with(