From patchwork Sat Feb 1 14:14:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 1232247 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 488x5p3gNXz9s29 for ; Sun, 2 Feb 2020 01:18:38 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: ozlabs.org; dkim=fail reason="key not found in DNS" header.d=that.guru header.i=@that.guru header.a=rsa-sha256 header.s=default header.b=AvQ2HPIw; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 488x5p38hZzDqgC for ; Sun, 2 Feb 2020 01:18:38 +1100 (AEDT) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=that.guru (client-ip=172.82.139.156; helo=qrelay156.mxroute.com; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" header.d=that.guru header.i=@that.guru header.a=rsa-sha256 header.s=default header.b=AvQ2HPIw; dkim-atps=neutral Received: from qrelay156.mxroute.com (qrelay156.mxroute.com [172.82.139.156]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 488x1q5mFhzDqfy for ; Sun, 2 Feb 2020 01:15:11 +1100 (AEDT) Received: from filter003.mxroute.com [168.235.111.26] (Authenticated sender: mN4UYu2MZsgR) by qrelay156.mxroute.com (ZoneMTA) with ESMTPA id 170011ae699000f036.002 for ; Sat, 01 Feb 2020 14:15:05 +0000 X-Zone-Loop: 9e0f9aafbaabb45f9bf79c8374aceaa123931e036524 X-Originating-IP: [168.235.111.26] Received: from one.mxroute.com (one.mxroute.com [195.201.59.211]) by filter003.mxroute.com (Postfix) with ESMTPS id 042B56004B; Sat, 1 Feb 2020 14:15:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=xEzmkwW4i5LKWiQMpmcEX1q4nvMVce8cVvBOGjR+m1g=; b=AvQ2HPIwvlEX1m/CwvLeLwARf8 HdmubkJMIhjLLemhFl3ZXg1yLWpwpHmAbsQHbgcLt0Vvox/MzklAU1uDzytHqu2qgcJ9r8EvGxh2r YqhxJj+PpndIFkpAQNrVu6SPZqgYpXq5WNMOUAfA9OmcAfNkHSUD2Ui11wvNjltyMTDfweutgljs+ IOGYWKBrGN2E8iP32wJOiddgMOY2PkjeahZvSIHfqKOlVfE9ScgbovlnA9gLtVnGjzYFgVfiTzUxJ Z+iZN/2bz58hDmSr0GnJqBKgstNpnibWEE30XYsrtHiuven2vt3HfDhJ6L2tCnWi0uclQ60CpspoG rJyq4HMQ==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH] Add regression tests for bug #335 Date: Sat, 1 Feb 2020 14:14:54 +0000 Message-Id: <20200201141454.13099-1-stephen@that.guru> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Signed-off-by: Stephen Finucane Cc: Mete Polat 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."""