From ab1c835fdf57e30effbc56ae6160bddb6969794c Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Sat, 1 Feb 2020 13:12:09 +0000 Subject: Add regression tests for bug #335 Signed-off-by: Stephen Finucane Cc: Mete Polat Related: #335 --- patchwork/tests/api/test_cover.py | 11 +++++++++++ patchwork/tests/api/test_event.py | 9 +++++++++ patchwork/tests/api/test_patch.py | 11 +++++++++++ patchwork/tests/api/test_series.py | 8 ++++++++ 4 files changed, 39 insertions(+) diff --git a/patchwork/tests/api/test_cover.py b/patchwork/tests/api/test_cover.py index 0a0bf04..891c554 100644 --- a/patchwork/tests/api/test_cover.py +++ b/patchwork/tests/api/test_cover.py @@ -11,7 +11,9 @@ from django.urls import reverse from patchwork.tests.api import utils from patchwork.tests.utils import create_cover +from patchwork.tests.utils import create_covers from patchwork.tests.utils import create_maintainer +from patchwork.tests.utils import create_series from patchwork.tests.utils import create_user if settings.ENABLE_REST_API: @@ -120,6 +122,15 @@ class TestCoverLetterAPI(utils.APITestCase): self.assertNotIn('mbox', resp.data[0]) self.assertNotIn('web_url', resp.data[0]) + def test_list_bug_335(self): + """Ensure we retrieve the embedded series project once.""" + series = create_series() + create_covers(5, series=series) + + # FIXME(stephenfin): This should result in 2 queries + with self.assertNumQueries(3): + self.client.get(self.api_url()) + @utils.store_samples('cover-detail') def test_detail(self): """Validate we can get a specific cover letter.""" diff --git a/patchwork/tests/api/test_event.py b/patchwork/tests/api/test_event.py index c202a65..e0fca68 100644 --- a/patchwork/tests/api/test_event.py +++ b/patchwork/tests/api/test_event.py @@ -178,6 +178,15 @@ class TestEventAPI(utils.APITestCase): {'actor': 'foo-bar'}) self.assertEqual(len(events), len(resp.data)) + def test_list_bug_335(self): + """Ensure we retrieve the embedded series project once.""" + for _ in range(3): + self._create_events() + + # FIXME(stephenfin): This should result in 28 queries + with self.assertNumQueries(32): + self.client.get(self.api_url()) + def test_order_by_date_default(self): """Assert the default ordering is by date descending.""" self._create_events() diff --git a/patchwork/tests/api/test_patch.py b/patchwork/tests/api/test_patch.py index ef418e2..888a257 100644 --- a/patchwork/tests/api/test_patch.py +++ b/patchwork/tests/api/test_patch.py @@ -14,8 +14,10 @@ from patchwork.models import Patch from patchwork.tests.api import utils from patchwork.tests.utils import create_maintainer from patchwork.tests.utils import create_patch +from patchwork.tests.utils import create_patches from patchwork.tests.utils import create_person from patchwork.tests.utils import create_project +from patchwork.tests.utils import create_series from patchwork.tests.utils import create_state from patchwork.tests.utils import create_user @@ -208,6 +210,15 @@ class TestPatchAPI(utils.APITestCase): self.assertIn('url', resp.data[0]) self.assertNotIn('web_url', resp.data[0]) + def test_list_bug_335(self): + """Ensure we retrieve the embedded series project once.""" + series = create_series() + create_patches(5, series=series) + + # FIXME(stephenfin): This should result in 3 queries + with self.assertNumQueries(8): + self.client.get(self.api_url()) + @utils.store_samples('patch-detail') def test_detail(self): """Show a specific patch.""" diff --git a/patchwork/tests/api/test_series.py b/patchwork/tests/api/test_series.py index 1327912..4ad82fe 100644 --- a/patchwork/tests/api/test_series.py +++ b/patchwork/tests/api/test_series.py @@ -138,6 +138,14 @@ class TestSeriesAPI(utils.APITestCase): self.assertNotIn('mbox', resp.data[0]['cover_letter']) self.assertNotIn('web_url', resp.data[0]['patches'][0]) + def test_list_bug_335(self): + """Ensure we retrieve the embedded cover letter project once.""" + self._create_series() + + # FIXME(stephenfin): This should result in 4 queries + with self.assertNumQueries(5): + self.client.get(self.api_url()) + @utils.store_samples('series-detail') def test_detail(self): """Show series.""" -- cgit v1.2.3