Skip to content
Open
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
4 changes: 4 additions & 0 deletions pwclient/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
28 changes: 28 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'}
)