From 9dc46dbebb366bfed098f2f2e3e4fb580854fa8c Mon Sep 17 00:00:00 2001 From: Dezhen Lu Date: Fri, 20 Nov 2026 00:52:44 +0100 Subject: [PATCH] REST: Pass name filter to patch list 'pwclient list STR' passes the name to 'REST.patch_list', but the REST backend dropped it and listed all patches. Patchwork's patch list endpoint searches patch names with the 'q' parameter, so pass it there, as the XML-RPC backend already does with 'name__icontains'. Closes: #51 Signed-off-by: Dezhen Lu --- pwclient/api.py | 4 +++ ...est-list-name-filter-3b8f2c6d1e7a9054.yaml | 6 ++++ tests/test_api.py | 28 +++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 releasenotes/notes/rest-list-name-filter-3b8f2c6d1e7a9054.yaml diff --git a/pwclient/api.py b/pwclient/api.py index b9c21f0..85e33f5 100644 --- a/pwclient/api.py +++ b/pwclient/api.py @@ -829,6 +829,10 @@ def patch_list( if delegate is not None: filters['delegate'] = delegate + if name is not None: + # the REST API searches patch names with the 'q' parameter + filters['q'] = name + patches = self._list('patches', params=filters) return (self._patch_to_dict(patch) for patch in patches) diff --git a/releasenotes/notes/rest-list-name-filter-3b8f2c6d1e7a9054.yaml b/releasenotes/notes/rest-list-name-filter-3b8f2c6d1e7a9054.yaml new file mode 100644 index 0000000..1ae5276 --- /dev/null +++ b/releasenotes/notes/rest-list-name-filter-3b8f2c6d1e7a9054.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + The ``pwclient list`` command now filters patches by name with the REST + backend. Previously the ``STR`` argument was ignored and all patches were + listed. diff --git a/tests/test_api.py b/tests/test_api.py index a0273a9..573ea11 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -150,3 +150,31 @@ def test_rest_client__list(): actual = list(client._list('patches')) assert expected == actual + + +def test_rest_client__patch_list__name(): + """Validate that patch_list passes the name filter to the server.""" + client = api.REST( + 'https://patchwork.kernel.org/api', + username='user', + password='pass', + ) + + with mock.patch.object(client, '_list', return_value=[]) as mock_list: + list( + client.patch_list( + project='patchwork', + submitter=None, + delegate=None, + state=None, + archived=None, + msgid=None, + series=None, + name='foo', + hash=None, + ) + ) + + mock_list.assert_called_once_with( + 'patches', params={'project': 'patchwork', 'q': 'foo'} + )