-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't exit if multiple matches found for a filter
Previously, specifying a filter that returned multiple results would result in an error. This made sense for API v1.0 because filters could only be specified once. However, this is not necessarily the case for v1.1, which does support multiple filters. In addition, it was inconsistent for v1.0, as specifying multiple filters on the command line would result in a warning, not an error. Resolve this by only warning the user if multiple matches are found for a given filter. This requires adding a check to ensure at least three characters are provided for the filter so as not to make it too generic. Signed-off-by: Stephen Finucane <[email protected]>
- Loading branch information
1 parent
4e0f7ba
commit de892d9
Showing
9 changed files
with
139 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
releasenotes/notes/filter-multiple-matches-197ff839f6b578da.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
features: | ||
- | | ||
Filtering patches, bundles and series by user will now only display a | ||
warning if multiple matches are found for a given filter and you're using | ||
API v1.0. Previously this would have been an unconditional error. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -337,35 +337,31 @@ def test_list_with_filters(self, mock_index, mock_version): | |
|
||
mock_index.assert_has_calls(calls) | ||
|
||
@mock.patch('git_pw.patch.LOG') | ||
def test_list_with_invalid_filters(self, mock_log, mock_index, | ||
mock_version): | ||
"""Validate behavior with filters applied. | ||
@mock.patch('git_pw.api.LOG') | ||
def test_list_with_wildcard_filters(self, mock_log, mock_index, | ||
mock_version): | ||
"""Validate behavior with a "wildcard" filter. | ||
Try to filter against a sumbmitter filter that's too broad. This should | ||
error out saying that too many possible submitters were found. | ||
Patchwork API v1.0 did not support multiple filters correctly. Ensure | ||
the user is warned as necessary if a filter has multiple matches. | ||
""" | ||
|
||
people_rsp = [self._get_person(), self._get_person()] | ||
patch_rsp = [self._get_patch()] | ||
mock_index.side_effect = [people_rsp, patch_rsp] | ||
|
||
runner = CLIRunner() | ||
result = runner.invoke(patch.list_cmd, ['--submitter', | ||
'[email protected]']) | ||
runner.invoke(patch.list_cmd, ['--submitter', '[email protected]']) | ||
|
||
assert result.exit_code == 1, result | ||
assert mock_log.error.called | ||
|
||
mock_index.side_effect = [people_rsp, patch_rsp] | ||
assert mock_log.warning.called | ||
|
||
@mock.patch('git_pw.api.LOG') | ||
def test_list_with_multiple_filters(self, mock_log, mock_index, | ||
mock_version): | ||
"""Validate behavior with use of multiple filters. | ||
Patchwork API v1.0 did not support multiple filters correctly. Ensure | ||
the user is warned as necessary. | ||
the user is warned as necessary if they specify multiple filters. | ||
""" | ||
|
||
people_rsp = [self._get_person()] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -187,33 +187,31 @@ def test_list_with_filters(self, mock_index, mock_version): | |
|
||
mock_index.assert_has_calls(calls) | ||
|
||
@mock.patch('git_pw.series.LOG') | ||
def test_list_with_invalid_filters(self, mock_log, mock_index, | ||
mock_version): | ||
"""Validate behavior with filters applied. | ||
@mock.patch('git_pw.api.LOG') | ||
def test_list_with_wildcard_filters(self, mock_log, mock_index, | ||
mock_version): | ||
"""Validate behavior with a "wildcard" filter. | ||
Try to filter against a sumbmitter filter that's too broad. This should | ||
error out saying that too many possible submitters were found. | ||
Patchwork API v1.0 did not support multiple filters correctly. Ensure | ||
the user is warned as necessary if a filter has multiple matches. | ||
""" | ||
|
||
people_rsp = [self._get_people(), self._get_people()] | ||
series_rsp = [self._get_series()] | ||
mock_index.side_effect = [people_rsp, series_rsp] | ||
|
||
runner = CLIRunner() | ||
result = runner.invoke(series.list_cmd, ['--submitter', | ||
'[email protected]']) | ||
runner.invoke(series.list_cmd, ['--submitter', '[email protected]']) | ||
|
||
assert result.exit_code == 1, result | ||
assert mock_log.error.called | ||
assert mock_log.warning.called | ||
|
||
@mock.patch('git_pw.api.LOG') | ||
def test_list_with_multiple_filters(self, mock_log, mock_index, | ||
mock_version): | ||
"""Validate behavior with use of multiple filters. | ||
Patchwork API v1.0 did not support multiple filters correctly. Ensure | ||
the user is warned as necessary. | ||
the user is warned as necessary if they specify multiple filters. | ||
""" | ||
|
||
people_rsp = [self._get_people()] | ||
|