aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Finucane <stephen@that.guru>2020-03-12 15:11:09 +0000
committerStephen Finucane <stephen@that.guru>2020-03-12 15:29:27 +0000
commit00808edcfe99689324dc6b28ef1b70dd4d7ab224 (patch)
tree098d3abc66342a69c7c125ae53533858623ea7a0
parent6cbfc2a43f19182942ad425877f0c5a4d3d7200f (diff)
downloadpatchwork-00808edcfe99689324dc6b28ef1b70dd4d7ab224.tar
patchwork-00808edcfe99689324dc6b28ef1b70dd4d7ab224.tar.gz
tests: Add tests for invalid cover/patch IDs
Signed-off-by: Stephen Finucane <stephen@that.guru> Related: #343
-rw-r--r--patchwork/tests/test_detail.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/patchwork/tests/test_detail.py b/patchwork/tests/test_detail.py
index 32fbfaf..92fe2d7 100644
--- a/patchwork/tests/test_detail.py
+++ b/patchwork/tests/test_detail.py
@@ -9,6 +9,7 @@ from django.urls import reverse
from patchwork.tests.utils import create_comment
from patchwork.tests.utils import create_cover
from patchwork.tests.utils import create_patch
+from patchwork.tests.utils import create_project
class CoverLetterViewTest(TestCase):
@@ -50,6 +51,23 @@ class CoverLetterViewTest(TestCase):
response = self.client.get(requested_url)
self.assertRedirects(response, redirect_url)
+ def test_invalid_project_id(self):
+ requested_url = reverse(
+ 'cover-detail',
+ kwargs={'project_id': 'foo', 'msgid': 'bar'},
+ )
+ response = self.client.get(requested_url)
+ self.assertEqual(response.status_code, 404)
+
+ def test_invalid_cover_id(self):
+ project = create_project()
+ requested_url = reverse(
+ 'cover-detail',
+ kwargs={'project_id': project.linkname, 'msgid': 'foo'},
+ )
+ response = self.client.get(requested_url)
+ self.assertEqual(response.status_code, 404)
+
class PatchViewTest(TestCase):
@@ -121,6 +139,23 @@ class PatchViewTest(TestCase):
response = self.client.get(requested_url)
self.assertNotIn('<b>TEST</b>'.encode('utf-8'), response.content)
+ def test_invalid_project_id(self):
+ requested_url = reverse(
+ 'patch-detail',
+ kwargs={'project_id': 'foo', 'msgid': 'bar'},
+ )
+ response = self.client.get(requested_url)
+ self.assertEqual(response.status_code, 404)
+
+ def test_invalid_patch_id(self):
+ project = create_project()
+ requested_url = reverse(
+ 'patch-detail',
+ kwargs={'project_id': project.linkname, 'msgid': 'foo'},
+ )
+ response = self.client.get(requested_url)
+ self.assertEqual(response.status_code, 404)
+
class CommentRedirectTest(TestCase):