[Patchew-devel] [PATCH] rest: add support for series DELETE in the REST API, and a corresponding unit test
Shubham Jain
shubhamjain7495 at gmail.com
Thu Mar 29 05:46:21 UTC 2018
---
api/rest.py | 2 +-
tests/test_rest.py | 13 +++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/api/rest.py b/api/rest.py
index 7c131a4..e966559 100644
--- a/api/rest.py
+++ b/api/rest.py
@@ -231,7 +231,7 @@ class SeriesViewSet(BaseMessageViewSet):
search_fields = (SEARCH_PARAM,)
class ProjectSeriesViewSet(ProjectMessagesViewSetMixin,
- SeriesViewSet):
+ SeriesViewSet,mixins.DestroyModelMixin):
def collect_patches(self, series):
if series.is_patch:
patches = [series]
diff --git a/tests/test_rest.py b/tests/test_rest.py
index 28ca10b..458f54e 100755
--- a/tests/test_rest.py
+++ b/tests/test_rest.py
@@ -218,6 +218,19 @@ class RestTest(PatchewTestCase):
resp = self.api_client.get(self.REST_BASE + 'projects/12345/series/?q=project:QEMU')
self.assertEqual(resp.data['count'], 0)
+ def test_series_delete(self):
+ resp1 = self.apply_and_retrieve('0001-simple-patch.mbox.gz',
+ self.p.id, '20160628014747.20971-1-famz at redhat.com')
+
+ resp_before = self.api_client.get(self.REST_BASE + 'projects/' + str(self.p.id) + '/series/20160628014747.20971-1-famz at redhat.com/')
+ self.assertEqual(resp_before.status_code, 200)
+
+ resp = self.api_client.delete(self.REST_BASE + 'projects/' + str(self.p.id) + '/series/20160628014747.20971-1-famz at redhat.com/')
+ self.assertEqual(resp.status_code, 204)
+
+ resp_after = self.api_client.get(self.REST_BASE + 'projects/' + str(self.p.id) + '/series/20160628014747.20971-1-famz at redhat.com/')
+ self.assertEqual(resp_after.status_code, 404)
+
def test_message(self):
series = self.apply_and_retrieve('0001-simple-patch.mbox.gz',
self.p.id, '20160628014747.20971-1-famz at redhat.com')
--
2.14.3 (Apple Git-98)
More information about the Patchew-devel
mailing list