[PATCH] Add regression tests for bug #335
Stephen Finucane
stephen at that.guru
Sun Feb 2 01:14:54 AEDT 2020
Signed-off-by: Stephen Finucane <stephen at that.guru>
Cc: Mete Polat <metepolat2000 at gmail.com>
Related: #335
---
patchwork/tests/api/test_cover.py | 11 +++++++++++
patchwork/tests/api/test_event.py | 8 ++++++++
patchwork/tests/api/test_patch.py | 11 +++++++++++
patchwork/tests/api/test_series.py | 8 ++++++++
4 files changed, 38 insertions(+)
diff --git a/patchwork/tests/api/test_cover.py b/patchwork/tests/api/test_cover.py
index 0a0bf041..5fe270bb 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_foo(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 c202a650..3bbcc5d8 100644
--- a/patchwork/tests/api/test_event.py
+++ b/patchwork/tests/api/test_event.py
@@ -178,6 +178,14 @@ class TestEventAPI(utils.APITestCase):
{'actor': 'foo-bar'})
self.assertEqual(len(events), len(resp.data))
+ def test_list_bug_foo(self):
+ """Ensure we retrieve the embedded series project once."""
+ self._create_events()
+
+ # FIXME(stephenfin): This should result in fewer (how many?) queries
+ with self.assertNumQueries(18):
+ 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 ef418e2e..efdf74e4 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_foo(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 13279120..7d042ab6 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_foo(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."""
--
2.24.1
More information about the Patchwork
mailing list