From: Stephen Finucane Date: Thu, 6 Sep 2018 17:11:55 +0000 (+0100) Subject: tests: Add more tests for series-ified mbox views X-Git-Tag: v2.2.0-rc1~240 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=29e6a8c812873d1aee2e18c9e7187d678e764738;p=thirdparty%2Fpatchwork.git 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 Reviewed-by: Daniel Axtens --- diff --git a/patchwork/tests/test_mboxviews.py b/patchwork/tests/test_mboxviews.py index eadfd81c..63191a17 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)