diff options
author | Stephen Finucane <stephen@that.guru> | 2020-02-01 13:12:09 +0000 |
---|---|---|
committer | Stephen Finucane <stephen@that.guru> | 2020-02-02 10:49:23 +0000 |
commit | ab1c835fdf57e30effbc56ae6160bddb6969794c (patch) | |
tree | 7ac64c0ecbbc4d73a84750bd6af47f1ff3b73a7a | |
parent | 1633afe5b46042d522777f66b1959a82298d0ab2 (diff) | |
download | patchwork-ab1c835fdf57e30effbc56ae6160bddb6969794c.tar patchwork-ab1c835fdf57e30effbc56ae6160bddb6969794c.tar.gz |
Add regression tests for bug #335
Signed-off-by: Stephen Finucane <stephen@that.guru>
Cc: Mete Polat <metepolat2000@gmail.com>
Related: #335
-rw-r--r-- | patchwork/tests/api/test_cover.py | 11 | ||||
-rw-r--r-- | patchwork/tests/api/test_event.py | 9 | ||||
-rw-r--r-- | patchwork/tests/api/test_patch.py | 11 | ||||
-rw-r--r-- | patchwork/tests/api/test_series.py | 8 |
4 files changed, 39 insertions, 0 deletions
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.""" |