Skip to content

Commit 359a618

Browse files
acervstephenfin
authored andcommitted
list: Add --series filter to list patches by series ID
The Patchwork REST API supports filtering patches by series ID but pwclient had no way to use it. Add -S/--series option to the list command so users can query patches belonging to a specific series without resorting to raw API calls. Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
1 parent e45a0d7 commit 359a618

File tree

6 files changed

+54
-0
lines changed

6 files changed

+54
-0
lines changed

pwclient/api.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def patch_list(
6767
state,
6868
archived,
6969
msgid,
70+
series,
7071
name,
7172
hash,
7273
max_count=None,
@@ -248,6 +249,7 @@ def patch_list(
248249
state,
249250
archived,
250251
msgid,
252+
series,
251253
name,
252254
hash,
253255
max_count=None,
@@ -263,6 +265,9 @@ def patch_list(
263265
if msgid:
264266
filters['msgid'] = msgid
265267

268+
if series:
269+
filters['series'] = series
270+
266271
if name:
267272
filters['name__icontains'] = name
268273

@@ -772,6 +777,7 @@ def patch_list(
772777
state,
773778
archived,
774779
msgid,
780+
series,
775781
name,
776782
hash,
777783
max_count=None,
@@ -797,6 +803,9 @@ def patch_list(
797803
if msgid is not None:
798804
filters['msgid'] = msgid
799805

806+
if series:
807+
filters['series'] = series
808+
800809
if archived is not None:
801810
filters['archived'] = archived
802811

pwclient/parser.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ def _get_filter_parser():
9999
filter_parser.add_argument(
100100
'-H', '--hash', metavar='HASH', help="filter by hash"
101101
)
102+
filter_parser.add_argument(
103+
'-S', '--series', metavar='SERIES_ID', help="filter by series ID"
104+
)
102105
filter_parser.add_argument(
103106
'-f',
104107
'--format',

pwclient/patches.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def action_list(
6666
state=None,
6767
archived=None,
6868
msgid=None,
69+
series=None,
6970
name=None,
7071
hash=None,
7172
max_count=None,
@@ -77,6 +78,7 @@ def action_list(
7778
'state': state,
7879
'archived': archived,
7980
'msgid': msgid,
81+
'series': series,
8082
'name': name,
8183
'hash': hash,
8284
'max_count': max_count,

pwclient/shell.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ def main(argv=sys.argv[1:]):
167167
state=args.state,
168168
archived=args.archived,
169169
msgid=args.msgid,
170+
series=args.series,
170171
name=args.patch_name,
171172
hash=args.hash,
172173
max_count=args.max_count,

tests/test_patches.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def test_action_list__no_submitter_no_delegate(mock_list_patches, capsys):
115115
state=None,
116116
archived=None,
117117
msgid=None,
118+
series=None,
118119
name=None,
119120
hash=None,
120121
max_count=None,
@@ -146,6 +147,7 @@ def test_action_list__submitter_filter(mock_list_patches, capsys):
146147
state=None,
147148
archived=None,
148149
msgid=None,
150+
series=None,
149151
name=None,
150152
hash=None,
151153
max_count=None,
@@ -174,6 +176,7 @@ def test_action_list__delegate_filter(mock_list_patches, capsys):
174176
state=None,
175177
archived=None,
176178
msgid=None,
179+
series=None,
177180
name=None,
178181
hash=None,
179182
max_count=None,

tests/test_shell.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ def test_list__no_options(mock_action, mock_api, mock_config):
620620
state=None,
621621
archived=None,
622622
msgid=None,
623+
series=None,
623624
name=None,
624625
hash=None,
625626
max_count=None,
@@ -644,6 +645,7 @@ def test_list__state_filter(mock_action, mock_api, mock_config):
644645
state='Accepted',
645646
archived=None,
646647
msgid=None,
648+
series=None,
647649
name=None,
648650
hash=None,
649651
max_count=None,
@@ -668,6 +670,7 @@ def test_list__archived_filter(mock_action, mock_api, mock_config):
668670
state=None,
669671
archived=True,
670672
msgid=None,
673+
series=None,
671674
name=None,
672675
hash=None,
673676
max_count=None,
@@ -698,6 +701,7 @@ def test_list__project_filter(mock_action, mock_api, mock_config):
698701
state=None,
699702
archived=None,
700703
msgid=None,
704+
series=None,
701705
name=None,
702706
hash=None,
703707
max_count=None,
@@ -722,6 +726,7 @@ def test_list__submitter_filter(mock_action, mock_api, mock_config):
722726
state=None,
723727
archived=None,
724728
msgid=None,
729+
series=None,
725730
name=None,
726731
hash=None,
727732
max_count=None,
@@ -746,6 +751,7 @@ def test_list__delegate_filter(mock_action, mock_api, mock_config):
746751
state=None,
747752
archived=None,
748753
msgid=None,
754+
series=None,
749755
name=None,
750756
hash=None,
751757
max_count=None,
@@ -770,6 +776,7 @@ def test_list__msgid_filter(mock_action, mock_api, mock_config):
770776
state=None,
771777
archived=None,
772778
msgid='fakemsgid',
779+
series=None,
773780
name=None,
774781
hash=None,
775782
max_count=None,
@@ -794,6 +801,7 @@ def test_list__name_filter(mock_action, mock_api, mock_config):
794801
state=None,
795802
archived=None,
796803
msgid=None,
804+
series=None,
797805
name='fake patch name',
798806
hash=None,
799807
max_count=None,
@@ -818,6 +826,7 @@ def test_list__limit_filter(mock_action, mock_api, mock_config):
818826
state=None,
819827
archived=None,
820828
msgid=None,
829+
series=None,
821830
name=None,
822831
hash=None,
823832
max_count=5,
@@ -842,6 +851,7 @@ def test_list__limit_reverse_filter(mock_action, mock_api, mock_config):
842851
state=None,
843852
archived=None,
844853
msgid=None,
854+
series=None,
845855
name=None,
846856
hash=None,
847857
max_count=-5,
@@ -866,13 +876,39 @@ def test_list__hash_filter(mock_action, mock_api, mock_config):
866876
state=None,
867877
archived=None,
868878
msgid=None,
879+
series=None,
869880
name=None,
870881
hash='3143a71a9d33f4f12b4469818d205125cace6535',
871882
max_count=None,
872883
format_str=None,
873884
)
874885

875886

887+
@mock.patch.object(utils.configparser, 'ConfigParser')
888+
@mock.patch.object(shell.os.path, 'exists', new=mock.Mock(return_value=True))
889+
@mock.patch.object(api, 'XMLRPC')
890+
@mock.patch.object(patches, 'action_list')
891+
def test_list__series_filter(mock_action, mock_api, mock_config):
892+
mock_config.return_value = FakeConfig()
893+
894+
shell.main(['list', '-S', '499314'])
895+
896+
mock_action.assert_called_once_with(
897+
mock_api.return_value,
898+
project=DEFAULT_PROJECT,
899+
submitter=None,
900+
delegate=None,
901+
state=None,
902+
archived=None,
903+
msgid=None,
904+
series='499314',
905+
name=None,
906+
hash=None,
907+
max_count=None,
908+
format_str=None,
909+
)
910+
911+
876912
@mock.patch.object(utils.configparser, 'ConfigParser')
877913
@mock.patch.object(shell.os.path, 'exists', new=mock.Mock(return_value=True))
878914
@mock.patch.object(api, 'XMLRPC')

0 commit comments

Comments
 (0)