From patchwork Tue Oct 30 11:31:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 990754 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42kq862Vjzz9s7W for ; Tue, 30 Oct 2018 22:32: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" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="O6DP0Xuf"; 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 42kq860R0CzDrPw for ; Tue, 30 Oct 2018 22:32:38 +1100 (AEDT) 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="O6DP0Xuf"; 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=159.100.240.208; helo=relay-ext2.mxrelay.co; 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="O6DP0Xuf"; dkim-atps=neutral Received: from relay-ext2.mxrelay.co (relay-ext2.mxrelay.co [159.100.240.208]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42kq7Z2sNkzDrPw for ; Tue, 30 Oct 2018 22:32:10 +1100 (AEDT) Received: from filter001.mxrelay.co (filter001.mxrelay.co [64.52.23.203]) by relay-ext2.mxrelay.co (Postfix) with ESMTP id 3F4BF3FC3F for ; Tue, 30 Oct 2018 11:32:06 +0000 (UTC) Received: from one.mxroute.com (one.mxroute.com [195.201.59.211]) by filter001.mxrelay.co (Postfix) with ESMTPS id 25BE31000C0 for ; Tue, 30 Oct 2018 11:32:05 +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=JrnvKkAUxkakWQDiHuW2UfIT0xoQLhVhfEwrxv2XmNM=; b=O6DP0XufCZUDmWOQuroDUV0klC K+detyMYjEJx31HrvGcX9PsRbFkag9+1p7xBCsS+OqKFx+F7TuKy/C96ihbwHmiwvaQBOwY26SRo4 gjc538MEHCdUgUYkchVEeVmmVfktao6fFaRdU6uioeMOVVgApJWNKN+DIUar3yJPf4TphmXXu9TcV f7ZUkdBhfBFi9D4kzWQItL+GG/Ll13Tr5/3VNCkI96IKmdztQjg6Yw0uHSWuGb9EPx/9inWwbq7u2 dfUCinr6/9Cr4dl+B3zUHfe27KXvrib6WB7RGWUcYCPc7KESHyjEXcBv78CSj39GL/MSd0xGm9OQq pqBjHyag==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 09/13] tests: Add 'store_samples' decorator to 'test_comment' Date: Tue, 30 Oct 2018 11:31:49 +0000 Message-Id: <20181030113153.7855-10-stephen@that.guru> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181030113153.7855-1-stephen@that.guru> References: <20181030113153.7855-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" Signed-off-by: Stephen Finucane --- patchwork/tests/api/test_comment.py | 57 ++++++++++++++++++----------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/patchwork/tests/api/test_comment.py b/patchwork/tests/api/test_comment.py index a0aec594..2ed2a35c 100644 --- a/patchwork/tests/api/test_comment.py +++ b/patchwork/tests/api/test_comment.py @@ -9,6 +9,7 @@ from django.conf import settings from django.urls import NoReverseMatch from django.urls import reverse +from patchwork.tests.api import utils from patchwork.tests.utils import create_comment from patchwork.tests.utils import create_cover from patchwork.tests.utils import create_patch @@ -40,26 +41,32 @@ class TestCoverComments(APITestCase): comment_json['submitter']['id']) self.assertIn(SAMPLE_CONTENT, comment_json['content']) - def test_list(self): - cover_obj = create_cover() - resp = self.client.get(self.api_url(cover_obj)) + def test_list_empty(self): + """List cover letter comments when none are present.""" + patch = create_cover() + resp = self.client.get(self.api_url(patch)) self.assertEqual(status.HTTP_200_OK, resp.status_code) self.assertEqual(0, len(resp.data)) - comment_obj = create_comment(submission=cover_obj) - resp = self.client.get(self.api_url(cover_obj)) + @utils.store_samples('cover-comment-list') + def test_list(self): + """List cover letter comments.""" + patch = create_cover() + comment = create_comment(submission=patch) + + resp = self.client.get(self.api_url(patch)) self.assertEqual(status.HTTP_200_OK, resp.status_code) self.assertEqual(1, len(resp.data)) - self.assertSerialized(comment_obj, resp.data[0]) + self.assertSerialized(comment, resp.data[0]) - create_comment(submission=cover_obj) - resp = self.client.get(self.api_url(cover_obj)) - self.assertEqual(status.HTTP_200_OK, resp.status_code) - self.assertEqual(2, len(resp.data)) + def test_list_version_1_0(self): + """List cover letter comments using API v1.0.""" + patch = create_cover() + create_comment(submission=patch) # check we can't access comments using the old version of the API with self.assertRaises(NoReverseMatch): - self.client.get(self.api_url(cover_obj, version='1.0')) + self.client.get(self.api_url(patch, version='1.0')) @unittest.skipUnless(settings.ENABLE_REST_API, 'requires ENABLE_REST_API') @@ -79,23 +86,29 @@ class TestPatchComments(APITestCase): comment_json['submitter']['id']) self.assertIn(SAMPLE_CONTENT, comment_json['content']) - def test_list(self): - patch_obj = create_patch() - resp = self.client.get(self.api_url(patch_obj)) + def test_list_empty(self): + """List patch comments when none are present.""" + patch = create_patch() + resp = self.client.get(self.api_url(patch)) self.assertEqual(status.HTTP_200_OK, resp.status_code) self.assertEqual(0, len(resp.data)) - comment_obj = create_comment(submission=patch_obj) - resp = self.client.get(self.api_url(patch_obj)) + @utils.store_samples('patch-comment-list') + def test_list(self): + """List patch comments.""" + patch = create_patch() + comment = create_comment(submission=patch) + + resp = self.client.get(self.api_url(patch)) self.assertEqual(status.HTTP_200_OK, resp.status_code) self.assertEqual(1, len(resp.data)) - self.assertSerialized(comment_obj, resp.data[0]) + self.assertSerialized(comment, resp.data[0]) - create_comment(submission=patch_obj) - resp = self.client.get(self.api_url(patch_obj)) - self.assertEqual(status.HTTP_200_OK, resp.status_code) - self.assertEqual(2, len(resp.data)) + def test_list_version_1_0(self): + """List patch comments using API v1.0.""" + patch = create_patch() + create_comment(submission=patch) # check we can't access comments using the old version of the API with self.assertRaises(NoReverseMatch): - self.client.get(self.api_url(patch_obj, version='1.0')) + self.client.get(self.api_url(patch, version='1.0'))