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

Stephen Finucane stephen at that.guru
Sat Sep 22 03:51:01 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>
Reviewed-by: Daniel Axtens <dja at axtens.net>
---
 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 eadfd81c..9de9c762 100644
--- a/patchwork/tests/test_mboxviews.py
+++ b/patchwork/tests/test_mboxviews.py
@@ -17,6 +17,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
 
@@ -197,16 +198,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
@@ -216,3 +241,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