[PATCH 4/4] tests: Tweak comment API tests

Stephen Finucane stephen at that.guru
Fri Aug 27 03:18:31 AEST 2021


We were missing tests for 'GET /patch/{patch_id}/comment' (list patch
comments) and 'GET /cover/{cover_id}/comment' (list cover comments) when
using API version 1.2. In addition, we had effectively duplicated tests
by including explicit tests for API 1.3. These are unnecessary since we
default to testing against the latest version. Address both issues.

Signed-off-by: Stephen Finucane <stephen at that.guru>
---
 patchwork/tests/api/test_comment.py | 40 ++++++++++++++++-------------
 1 file changed, 22 insertions(+), 18 deletions(-)

diff --git patchwork/tests/api/test_comment.py patchwork/tests/api/test_comment.py
index 74acf447..5c035e82 100644
--- patchwork/tests/api/test_comment.py
+++ patchwork/tests/api/test_comment.py
@@ -69,6 +69,17 @@ class TestCoverComments(utils.APITestCase):
         self.assertEqual(1, len(resp.data))
         self.assertSerialized(comment, resp.data[0])
         self.assertIn('list_archive_url', resp.data[0])
+        self.assertIn('addressed', resp.data[0])
+
+    def test_list_version_1_2(self):
+        """List cover letter comments using API v1.2."""
+        create_cover_comment(cover=self.cover)
+
+        resp = self.client.get(self.api_url(self.cover, version='1.2'))
+        self.assertEqual(status.HTTP_200_OK, resp.status_code)
+        self.assertEqual(1, len(resp.data))
+        self.assertIn('list_archive_url', resp.data[0])
+        self.assertNotIn('addressed', resp.data[0])
 
     def test_list_version_1_1(self):
         """List cover letter comments using API v1.1."""
@@ -110,15 +121,6 @@ class TestCoverComments(utils.APITestCase):
         self.assertEqual(status.HTTP_200_OK, resp.status_code)
         self.assertSerialized(comment, resp.data)
 
-    def test_detail_version_1_3(self):
-        """Show a cover letter comment using API v1.3."""
-        comment = create_cover_comment(cover=self.cover)
-
-        resp = self.client.get(
-            self.api_url(self.cover, version='1.3', item=comment))
-        self.assertEqual(status.HTTP_200_OK, resp.status_code)
-        self.assertSerialized(comment, resp.data)
-
     def test_detail_version_1_2(self):
         """Show a cover letter comment using API v1.2."""
         comment = create_cover_comment(cover=self.cover)
@@ -292,6 +294,17 @@ class TestPatchComments(utils.APITestCase):
         self.assertEqual(1, len(resp.data))
         self.assertSerialized(comment, resp.data[0])
         self.assertIn('list_archive_url', resp.data[0])
+        self.assertIn('addressed', resp.data[0])
+
+    def test_list_version_1_2(self):
+        """List patch comments using API v1.2."""
+        create_patch_comment(patch=self.patch)
+
+        resp = self.client.get(self.api_url(self.patch, version='1.2'))
+        self.assertEqual(status.HTTP_200_OK, resp.status_code)
+        self.assertEqual(1, len(resp.data))
+        self.assertIn('list_archive_url', resp.data[0])
+        self.assertNotIn('addressed', resp.data[0])
 
     def test_list_version_1_1(self):
         """List patch comments using API v1.1."""
@@ -333,15 +346,6 @@ class TestPatchComments(utils.APITestCase):
         self.assertEqual(status.HTTP_200_OK, resp.status_code)
         self.assertSerialized(comment, resp.data)
 
-    def test_detail_version_1_3(self):
-        """Show a patch comment using API v1.3."""
-        comment = create_patch_comment(patch=self.patch)
-
-        resp = self.client.get(
-            self.api_url(self.patch, version='1.3', item=comment))
-        self.assertEqual(status.HTTP_200_OK, resp.status_code)
-        self.assertSerialized(comment, resp.data)
-
     def test_detail_version_1_2(self):
         """Show a patch comment using API v1.2."""
         comment = create_patch_comment(patch=self.patch)
-- 
2.31.1



More information about the Patchwork mailing list