diff --git a/pwclient/api.py b/pwclient/api.py index 4ca2bc7..b736a41 100644 --- a/pwclient/api.py +++ b/pwclient/api.py @@ -67,6 +67,7 @@ def patch_list( state, archived, msgid, + series, name, hash, max_count=None, @@ -248,6 +249,7 @@ def patch_list( state, archived, msgid, + series, name, hash, max_count=None, @@ -263,6 +265,9 @@ def patch_list( if msgid: filters['msgid'] = msgid + if series: + filters['series'] = series + if name: filters['name__icontains'] = name @@ -772,6 +777,7 @@ def patch_list( state, archived, msgid, + series, name, hash, max_count=None, @@ -797,6 +803,9 @@ def patch_list( if msgid is not None: filters['msgid'] = msgid + if series: + filters['series'] = series + if archived is not None: filters['archived'] = archived diff --git a/pwclient/parser.py b/pwclient/parser.py index be5a194..be6dd72 100644 --- a/pwclient/parser.py +++ b/pwclient/parser.py @@ -99,6 +99,9 @@ def _get_filter_parser(): filter_parser.add_argument( '-H', '--hash', metavar='HASH', help="filter by hash" ) + filter_parser.add_argument( + '-S', '--series', metavar='SERIES_ID', help="filter by series ID" + ) filter_parser.add_argument( '-f', '--format', diff --git a/pwclient/patches.py b/pwclient/patches.py index e4492a8..eb5b8b0 100644 --- a/pwclient/patches.py +++ b/pwclient/patches.py @@ -66,6 +66,7 @@ def action_list( state=None, archived=None, msgid=None, + series=None, name=None, hash=None, max_count=None, @@ -77,6 +78,7 @@ def action_list( 'state': state, 'archived': archived, 'msgid': msgid, + 'series': series, 'name': name, 'hash': hash, 'max_count': max_count, diff --git a/pwclient/shell.py b/pwclient/shell.py index 7361827..a3a9f27 100644 --- a/pwclient/shell.py +++ b/pwclient/shell.py @@ -167,6 +167,7 @@ def main(argv=sys.argv[1:]): state=args.state, archived=args.archived, msgid=args.msgid, + series=args.series, name=args.patch_name, hash=args.hash, max_count=args.max_count, diff --git a/tests/test_patches.py b/tests/test_patches.py index a222e68..09b6e98 100644 --- a/tests/test_patches.py +++ b/tests/test_patches.py @@ -115,6 +115,7 @@ def test_action_list__no_submitter_no_delegate(mock_list_patches, capsys): state=None, archived=None, msgid=None, + series=None, name=None, hash=None, max_count=None, @@ -146,6 +147,7 @@ def test_action_list__submitter_filter(mock_list_patches, capsys): state=None, archived=None, msgid=None, + series=None, name=None, hash=None, max_count=None, @@ -174,6 +176,7 @@ def test_action_list__delegate_filter(mock_list_patches, capsys): state=None, archived=None, msgid=None, + series=None, name=None, hash=None, max_count=None, diff --git a/tests/test_shell.py b/tests/test_shell.py index 2330728..63f7dbe 100644 --- a/tests/test_shell.py +++ b/tests/test_shell.py @@ -620,6 +620,7 @@ def test_list__no_options(mock_action, mock_api, mock_config): state=None, archived=None, msgid=None, + series=None, name=None, hash=None, max_count=None, @@ -644,6 +645,7 @@ def test_list__state_filter(mock_action, mock_api, mock_config): state='Accepted', archived=None, msgid=None, + series=None, name=None, hash=None, max_count=None, @@ -668,6 +670,7 @@ def test_list__archived_filter(mock_action, mock_api, mock_config): state=None, archived=True, msgid=None, + series=None, name=None, hash=None, max_count=None, @@ -698,6 +701,7 @@ def test_list__project_filter(mock_action, mock_api, mock_config): state=None, archived=None, msgid=None, + series=None, name=None, hash=None, max_count=None, @@ -722,6 +726,7 @@ def test_list__submitter_filter(mock_action, mock_api, mock_config): state=None, archived=None, msgid=None, + series=None, name=None, hash=None, max_count=None, @@ -746,6 +751,7 @@ def test_list__delegate_filter(mock_action, mock_api, mock_config): state=None, archived=None, msgid=None, + series=None, name=None, hash=None, max_count=None, @@ -770,6 +776,7 @@ def test_list__msgid_filter(mock_action, mock_api, mock_config): state=None, archived=None, msgid='fakemsgid', + series=None, name=None, hash=None, max_count=None, @@ -794,6 +801,7 @@ def test_list__name_filter(mock_action, mock_api, mock_config): state=None, archived=None, msgid=None, + series=None, name='fake patch name', hash=None, max_count=None, @@ -818,6 +826,7 @@ def test_list__limit_filter(mock_action, mock_api, mock_config): state=None, archived=None, msgid=None, + series=None, name=None, hash=None, max_count=5, @@ -842,6 +851,7 @@ def test_list__limit_reverse_filter(mock_action, mock_api, mock_config): state=None, archived=None, msgid=None, + series=None, name=None, hash=None, max_count=-5, @@ -866,6 +876,7 @@ def test_list__hash_filter(mock_action, mock_api, mock_config): state=None, archived=None, msgid=None, + series=None, name=None, hash='3143a71a9d33f4f12b4469818d205125cace6535', max_count=None, @@ -873,6 +884,31 @@ def test_list__hash_filter(mock_action, mock_api, mock_config): ) +@mock.patch.object(utils.configparser, 'ConfigParser') +@mock.patch.object(shell.os.path, 'exists', new=mock.Mock(return_value=True)) +@mock.patch.object(api, 'XMLRPC') +@mock.patch.object(patches, 'action_list') +def test_list__series_filter(mock_action, mock_api, mock_config): + mock_config.return_value = FakeConfig() + + shell.main(['list', '-S', '499314']) + + mock_action.assert_called_once_with( + mock_api.return_value, + project=DEFAULT_PROJECT, + submitter=None, + delegate=None, + state=None, + archived=None, + msgid=None, + series='499314', + name=None, + hash=None, + max_count=None, + format_str=None, + ) + + @mock.patch.object(utils.configparser, 'ConfigParser') @mock.patch.object(shell.os.path, 'exists', new=mock.Mock(return_value=True)) @mock.patch.object(api, 'XMLRPC')