From patchwork Fri Sep 21 17:51:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 973377 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42H1QB0Vfrz9sCS for ; Sat, 22 Sep 2018 03:52:18 +1000 (AEST) 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" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="fkB2r8mg"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42H1Q9241CzF3SF for ; Sat, 22 Sep 2018 03:52:17 +1000 (AEST) 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" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="fkB2r8mg"; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=that.guru (client-ip=185.234.75.9; helo=relay002.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" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="fkB2r8mg"; dkim-atps=neutral Received: from relay002.mxroute.com (relay002.mxroute.com [185.234.75.9]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42H1PW39f6zF3SV for ; Sat, 22 Sep 2018 03:51:43 +1000 (AEST) Received: from filter002.mxroute.com (unknown [185.133.192.179]) by relay002.mxroute.com (Postfix) with ESMTP id EEA963F152 for ; Fri, 21 Sep 2018 17:51:10 +0000 (UTC) Received: from one.mxroute.com (one.mxroute.com [195.201.59.211]) by filter002.mxroute.com (Postfix) with ESMTPS id C06D63F3BD for ; Fri, 21 Sep 2018 17:51:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=3CkNSRyXjvoks2yqKXitW2EQ56N913tZwHnJqPhS0Tk=; b=fkB2r8mgfaT6cVR4Y62m9LvusK x8W2Lt5phby8tg/tVtAmg4fN1y4ReXnzxZMtfhPkl1wXIZex8V3axNxgQCWIkRmFASS6u+BBK2tz0 +47+E5xl4PFmYJmaFA93F7UCBFPbOsp881FqUOGztrqwiNgtq0mHI4PpYywUD2T0qtARMmn6afuc+ MNNx32wcXQTtv6seaGa+WZPjNNs79iaZC9LLRif5pfOJ7jhyrd1j2QhQS5g2Z4swUYNr5pDq8v/nb EFZVA5lF2PCQFoVQOTweJJ5S4bqv6N1KOHwy1UdN0a+Jt7/y03+cCdB80ih8BUI8WjxQckrkqV95c Bp+aqCgw==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH v3 1/5] tests: Add more tests for series-ified mbox views Date: Fri, 21 Sep 2018 18:51:01 +0100 Message-Id: <20180921175105.18000-2-stephen@that.guru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180921175105.18000-1-stephen@that.guru> References: <20180921175105.18000-1-stephen@that.guru> 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: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" 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 --- patchwork/tests/test_mboxviews.py | 40 ++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/patchwork/tests/test_mboxviews.py b/patchwork/tests/test_mboxviews.py index eadfd81c..9de9c762 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)