[PATCH v2 1/5] tests: Add more tests for series-ified mbox views

Stephen Finucane stephen at that.guru
Tue Sep 11 08:37:08 AEST 2018


Cover some testing gaps identified during the migration from a M:N to a
1:N series-patch relationship, namely:

- Downloading a patch's mbox with dependencies using a numerical series
  ID
- Downloading a series' mbox

Signed-off-by: Stephen Finucane <stephen at that.guru>
---
 patchwork/tests/test_mboxviews.py | 40 ++++++++++++++++++++++++++++++-
 1 file changed, 39 insertions(+), 1 deletion(-)

diff --git a/patchwork/tests/test_mboxviews.py b/patchwork/tests/test_mboxviews.py
index b7af746b..ecf46674 100644
--- a/patchwork/tests/test_mboxviews.py
+++ b/patchwork/tests/test_mboxviews.py
@@ -31,6 +31,7 @@ from patchwork.tests.utils import create_comment
 from patchwork.tests.utils import create_patch
 from patchwork.tests.utils import create_project
 from patchwork.tests.utils import create_person
+from patchwork.tests.utils import create_series
 from patchwork.tests.utils import create_series_patch
 from patchwork.tests.utils import create_user
 
@@ -211,16 +212,40 @@ class MboxCommentPostcriptUnchangedTest(TestCase):
 
 class MboxSeriesDependencies(TestCase):
 
-    def test_patch_with_dependencies(self):
+    @staticmethod
+    def _create_patches():
         patch_a = create_series_patch()
         patch_b = create_series_patch(series=patch_a.series)
 
+        return patch_a.series, patch_a, patch_b
+
+    def test_patch_with_wildcard_series(self):
+        _, patch_a, patch_b = self._create_patches()
+
         response = self.client.get('%s?series=*' % reverse(
             'patch-mbox', args=[patch_b.patch.id]))
 
         self.assertContains(response, patch_a.patch.content)
         self.assertContains(response, patch_b.patch.content)
 
+    def test_patch_with_numeric_series(self):
+        series, patch_a, patch_b = self._create_patches()
+
+        response = self.client.get('%s?series=%d' % (
+            reverse('patch-mbox', args=[patch_b.patch.id]), series.id))
+
+        self.assertContains(response, patch_a.patch.content)
+        self.assertContains(response, patch_b.patch.content)
+
+    def test_patch_with_invalid_series(self):
+        series, patch_a, patch_b = self._create_patches()
+
+        for value in ('foo', str(series.id + 1)):
+            response = self.client.get('%s?series=%s' % (
+                reverse('patch-mbox', args=[patch_b.patch.id]), value))
+
+        self.assertEqual(response.status_code, 404)
+
     def test_legacy_patch(self):
         """Validate a patch with non-existent dependencies raises a 404."""
         # we're explicitly creating a patch without a series
@@ -230,3 +255,16 @@ class MboxSeriesDependencies(TestCase):
             'patch-mbox', args=[patch.id]))
 
         self.assertEqual(response.status_code, 404)
+
+
+class MboxSeries(TestCase):
+
+    def test_series(self):
+        series = create_series()
+        patch_a = create_series_patch(series=series)
+        patch_b = create_series_patch(series=series)
+
+        response = self.client.get(reverse('series-mbox', args=[series.id]))
+
+        self.assertContains(response, patch_a.patch.content)
+        self.assertContains(response, patch_b.patch.content)
-- 
2.17.1



More information about the Patchwork mailing list