summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Finucane <stephen@that.guru>2018-09-06 18:11:55 +0100
committerStephen Finucane <stephen@that.guru>2018-10-17 18:37:51 +0100
commit29e6a8c812873d1aee2e18c9e7187d678e764738 (patch)
treeb9ab37589e219c074e261a6b0bd621b0630ab873
parent810d2c92016b2e58ba97fb3c5b18c5255af8ddb4 (diff)
downloadpatchwork-29e6a8c812873d1aee2e18c9e7187d678e764738.tar
patchwork-29e6a8c812873d1aee2e18c9e7187d678e764738.tar.gz
tests: Add more tests for series-ified mbox views
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@that.guru> Reviewed-by: Daniel Axtens <dja@axtens.net>
-rw-r--r--patchwork/tests/test_mboxviews.py40
1 files changed, 39 insertions, 1 deletions
diff --git a/patchwork/tests/test_mboxviews.py b/patchwork/tests/test_mboxviews.py
index eadfd81..63191a1 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)