-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api: allow filtering patches and covers by msgid
In the process of fixing the previous bug, I realised that: a) /api/patches/msgid is a perfectly reasonable thing to attempt b) We have no way of finding a patch by message id in the API We can't actualy make /api/patches/msgid work because it may not be unique, but we can add a filter. I'm shoehorning this into stable/2.2, even though it's technically an API change: it's minor, not incompatible and in hindsight a glaring hole. Cc: Michael Ellerman <[email protected]> Tested-by: Jeremy Kerr <[email protected]> Reviewed-by: Andrew Donnellan <[email protected]> Reviewed-by: Stephen Finucane <[email protected]> Signed-off-by: Daniel Axtens <[email protected]> (cherry picked from commit d08b6c7)
- Loading branch information
Showing
7 changed files
with
90 additions
and
4 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
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 |
---|---|---|
|
@@ -111,6 +111,18 @@ def test_list_filter_submitter(self): | |
'submitter': '[email protected]'}) | ||
self.assertEqual(0, len(resp.data)) | ||
|
||
def test_list_filter_msgid(self): | ||
"""Filter covers by msgid.""" | ||
cover = create_cover() | ||
|
||
resp = self.client.get(self.api_url(), {'msgid': cover.url_msgid}) | ||
self.assertEqual([cover.id], [x['id'] for x in resp.data]) | ||
|
||
# empty response if nothing matches | ||
resp = self.client.get(self.api_url(), { | ||
'msgid': '[email protected]'}) | ||
self.assertEqual(0, len(resp.data)) | ||
|
||
@utils.store_samples('cover-list-1-0') | ||
def test_list_version_1_0(self): | ||
create_cover() | ||
|
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 |
---|---|---|
|
@@ -199,6 +199,18 @@ def test_list_filter_hash_version_1_1(self): | |
{'hash': 'garbagevalue'}) | ||
self.assertEqual(1, len(resp.data)) | ||
|
||
def test_list_filter_msgid(self): | ||
"""Filter patches by msgid.""" | ||
patch = self._create_patch() | ||
|
||
resp = self.client.get(self.api_url(), {'msgid': patch.url_msgid}) | ||
self.assertEqual([patch.id], [x['id'] for x in resp.data]) | ||
|
||
# empty response if nothing matches | ||
resp = self.client.get(self.api_url(), { | ||
'msgid': '[email protected]'}) | ||
self.assertEqual(0, len(resp.data)) | ||
|
||
@utils.store_samples('patch-list-1-0') | ||
def test_list_version_1_0(self): | ||
"""List patches using API v1.0.""" | ||
|
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 @@ | ||
--- | ||
api: | ||
- | | ||
The REST API now supports filtering patches and cover letters by message | ||
ID, using the ``msgid`` query parameter. Don't include leading or trailing | ||
angle brackets. |