Skip to content

Commit

Permalink
tests: Tweak comment API tests
Browse files Browse the repository at this point in the history
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@that.guru>
  • Loading branch information
stephenfin committed Oct 28, 2021
1 parent f5cd521 commit 7e67aeb
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions patchwork/tests/api/test_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ def test_list(self):
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."""
Expand Down Expand Up @@ -110,15 +121,6 @@ def test_detail(self):
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)
Expand Down Expand Up @@ -292,6 +294,17 @@ def test_list(self):
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."""
Expand Down Expand Up @@ -333,15 +346,6 @@ def test_detail(self):
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)
Expand Down

0 comments on commit 7e67aeb

Please sign in to comment.