From patchwork Wed Sep 12 15:46:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 969079 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 429R4Z17kJz9sB5 for ; Thu, 13 Sep 2018 01:47:42 +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="Leb1VYqt"; 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 429R4Y6b2WzF37b for ; Thu, 13 Sep 2018 01:47:41 +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="Leb1VYqt"; 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.3; helo=relay-direct21.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="Leb1VYqt"; dkim-atps=neutral Received: from relay-direct21.mxroute.com (relay-direct21.mxroute.com [185.234.75.3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 429R4T09W4zF37B for ; Thu, 13 Sep 2018 01:47:36 +1000 (AEST) Received: from filter002.mxroute.com (unknown [185.133.192.179]) by relay-direct21.mxroute.com (Postfix) with ESMTP id 000373FD0B; Wed, 12 Sep 2018 15:47:03 +0000 (UTC) Received: from one.mxroute.com (one.mxroute.com [195.201.59.211]) by filter002.mxroute.com (Postfix) with ESMTPS id BFEA63F3AF; Wed, 12 Sep 2018 15:47:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=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: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=aavlxpRLnIxX/THNrLqxiK+QOkYuFxuz4Z1j32IT/kI=; b=Leb1VYqtyaREEGKocHBokUrR39 Sz601sh8UTyJ2WYhrW7IYlgBiOmac8/wD4sw7XdLMeiibTGX7Cr+pbSehWDvtHrV+WjG1gykmo0K1 xDFKOqLWiTwo3lmV1nca1Lm8G+spdxkbpKcjhfe3+YhEsmhJwitXG72jWcnYjKv0CyytATjjM0jjY GhrvIuibBf1WtI4V6ajICg60l/zY6v/5RfViKHTnNx55wWcqKTvbidPcsp9pgXFi9Ek2a+0yhHNJy DouzDVUY8Idz9MRO9D+y+D45hT6YHn93CTjnBKxAo5VtGeJDeOY4IXNcxr5IVcPaZ6u4NK8Axz8MO i/XgpWyA==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH] REST: Only list checks for the given patch Date: Wed, 12 Sep 2018 09:46:56 -0600 Message-Id: <20180912154656.20077-1-stephen@that.guru> X-Mailer: git-send-email 2.17.1 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: , Cc: Michael Ellerman MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" This is either a regression or it never worked. In any case, fix it and add a test to ensure it doesn't happen again. Signed-off-by: Stephen Finucane Cc: Michael Ellerman Closes: #203 Reviewed-by: Veronika Kabatova --- patchwork/api/check.py | 3 ++- patchwork/tests/api/test_check.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/patchwork/api/check.py b/patchwork/api/check.py index 5e461de6..712238eb 100644 --- a/patchwork/api/check.py +++ b/patchwork/api/check.py @@ -83,7 +83,8 @@ class CheckMixin(object): filter_class = CheckFilterSet def get_queryset(self): - return Check.objects.prefetch_related('patch', 'user') + patch_id = self.kwargs['patch_id'] + return Check.objects.prefetch_related('user').filter(patch=patch_id) class CheckListCreate(CheckMixin, ListCreateAPIView): diff --git a/patchwork/tests/api/test_check.py b/patchwork/tests/api/test_check.py index 6f4aa5de..4c6a934c 100644 --- a/patchwork/tests/api/test_check.py +++ b/patchwork/tests/api/test_check.py @@ -54,9 +54,9 @@ class TestCheckAPI(APITestCase): self.user = create_maintainer(project) self.patch = create_patch(project=project) - def _create_check(self): + def _create_check(self, patch=None): values = { - 'patch': self.patch, + 'patch': patch if patch else self.patch, 'user': self.user, } return create_check(**values) @@ -76,6 +76,7 @@ class TestCheckAPI(APITestCase): self.assertEqual(0, len(resp.data)) check_obj = self._create_check() + self._create_check(create_patch()) # second, unrelated patch resp = self.client.get(self.api_url()) self.assertEqual(status.HTTP_200_OK, resp.status_code)