From patchwork Sun Dec 10 17:30:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 846682 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yvtRK2fWkz9sDB for ; Mon, 11 Dec 2017 04:31:09 +1100 (AEDT) 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="YtYG33HB"; 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 3yvtRJ3d2VzDr3x for ; Mon, 11 Dec 2017 04:31:08 +1100 (AEDT) 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="YtYG33HB"; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=that.guru (client-ip=23.83.214.17; helo=bird.maple.relay.mailchannels.net; envelope-from=stephen@that.guru; receiver=) 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="YtYG33HB"; dkim-atps=neutral Received: from bird.maple.relay.mailchannels.net (bird.maple.relay.mailchannels.net [23.83.214.17]) (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 3yvtR13PH0zDqy2 for ; Mon, 11 Dec 2017 04:30:51 +1100 (AEDT) X-Sender-Id: mxroute|x-authuser|stephen@that.guru Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 78EDF560643 for ; Sun, 10 Dec 2017 17:30:47 +0000 (UTC) Received: from one.mxroute.com (unknown [100.96.23.11]) (Authenticated sender: mxroute) by relay.mailchannels.net (Postfix) with ESMTPA id 161E0560661 for ; Sun, 10 Dec 2017 17:30:47 +0000 (UTC) X-Sender-Id: mxroute|x-authuser|stephen@that.guru Received: from one.mxroute.com (one-outgoing.mxroute.com [172.18.44.71]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.11.3); Sun, 10 Dec 2017 17:30:47 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: mxroute|x-authuser|stephen@that.guru X-MailChannels-Auth-Id: mxroute X-Trouble-Shade: 2352e29a163f7091_1512927047269_2433825373 X-MC-Loop-Signature: 1512927047269:1481485701 X-MC-Ingress-Time: 1512927047268 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=EyARGFtkxjdyDc656TJN/0cecn/+s4CdLXFNyN+lq88=; b=YtYG33HBjhAN5nq4la7gb19qDJ WJ8aXoAuSrUq9ixAO11EM3fTXCNtcpwChxQq1CH/aZLe4AFRTKkkexM50ApCbiHDwMQ0+xfOsK1xb d7JZM+HUZbWCjAWfo/UBFUyp8aAJk0Ksm96uVLxK34yLKcbOItK6CIJL7sly4HKrEhV70euuuVokr WyOFL722TWM/BJ7mWX4n+ZhR5KL+rWk+mNJT+jJf4A9CEYe2ep2Y/LrRA+00KBObw2atXWJ+VTfih XUJgdGyRkcssbF+vlTHFd8zh8ubrwDL8KdsyUmwNOhB8QdJFQNJcvzS7JjY609LbI2jIhILZnAe+O KE0i7iAg==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 2/4] tests: Validate filtering covers, series by project Date: Sun, 10 Dec 2017 17:30:33 +0000 Message-Id: <20171210173035.24778-2-stephen@that.guru> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171210173035.24778-1-stephen@that.guru> References: <20171210173035.24778-1-stephen@that.guru> X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.24 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" Signed-off-by: Stephen Finucane --- patchwork/tests/test_rest_api.py | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/patchwork/tests/test_rest_api.py b/patchwork/tests/test_rest_api.py index 14e53b28..87112d9f 100644 --- a/patchwork/tests/test_rest_api.py +++ b/patchwork/tests/test_rest_api.py @@ -493,7 +493,8 @@ class TestCoverLetterAPI(APITestCase): self.assertEqual(status.HTTP_200_OK, resp.status_code) self.assertEqual(0, len(resp.data)) - cover_obj = create_cover() + project_obj = create_project(linkname='myproject') + cover_obj = create_cover(project=project_obj) # anonymous user resp = self.client.get(self.api_url()) @@ -509,6 +510,12 @@ class TestCoverLetterAPI(APITestCase): self.assertEqual(1, len(resp.data)) self.assertSerialized(cover_obj, resp.data[0]) + # test filtering by project + resp = self.client.get(self.api_url(), {'project': 'myproject'}) + self.assertEqual([cover_obj.id], [x['id'] for x in resp.data]) + resp = self.client.get(self.api_url(), {'project': 'invalidproject'}) + self.assertEqual(0, len(resp.data)) + def test_detail(self): """Validate we can get a specific cover letter.""" cover_obj = create_cover() @@ -567,13 +574,14 @@ class TestSeriesAPI(APITestCase): self.assertEqual(status.HTTP_200_OK, resp.status_code) self.assertEqual(0, len(resp.data)) - series = create_series() + project_obj = create_project(linkname='myproject') + series_obj = create_series(project=project_obj) # anonymous user resp = self.client.get(self.api_url()) self.assertEqual(status.HTTP_200_OK, resp.status_code) self.assertEqual(1, len(resp.data)) - self.assertSerialized(series, resp.data[0]) + self.assertSerialized(series_obj, resp.data[0]) # authenticated user user = create_user() @@ -581,7 +589,13 @@ class TestSeriesAPI(APITestCase): resp = self.client.get(self.api_url()) self.assertEqual(status.HTTP_200_OK, resp.status_code) self.assertEqual(1, len(resp.data)) - self.assertSerialized(series, resp.data[0]) + self.assertSerialized(series_obj, resp.data[0]) + + # test filtering by project + resp = self.client.get(self.api_url(), {'project': 'myproject'}) + self.assertEqual([series_obj.id], [x['id'] for x in resp.data]) + resp = self.client.get(self.api_url(), {'project': 'invalidproject'}) + self.assertEqual(0, len(resp.data)) def test_detail(self): """Validate we can get a specific series.""" @@ -747,8 +761,11 @@ class TestBundleAPI(APITestCase): self.assertEqual(0, len(resp.data)) user = create_user() - bundle_public = create_bundle(public=True, owner=user) - bundle_private = create_bundle(public=False, owner=user) + project = create_project(linkname='myproject') + bundle_public = create_bundle(public=True, owner=user, + project=project) + bundle_private = create_bundle(public=False, owner=user, + project=project) # anonymous users # should only see the public bundle @@ -768,6 +785,13 @@ class TestBundleAPI(APITestCase): resp.data, [bundle_public, bundle_private]): self.assertSerialized(bundle_obj, bundle_rsp) + # test filtering by project + resp = self.client.get(self.api_url(), {'project': 'myproject'}) + self.assertEqual([bundle_public.id, bundle_private.id], + [x['id'] for x in resp.data]) + resp = self.client.get(self.api_url(), {'project': 'invalidproject'}) + self.assertEqual(0, len(resp.data)) + def test_detail(self): """Validate we can get a specific bundle.""" bundle = create_bundle(public=True)