From patchwork Fri Jun 24 16:28:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 640302 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 AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rbkKk1K84z9t12 for ; Sat, 25 Jun 2016 02:28:42 +1000 (AEST) Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3rbkKk0YyjzDqly for ; Sat, 25 Jun 2016 02:28:42 +1000 (AEST) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lists.ozlabs.org (Postfix) with ESMTP id 3rbkKQ1BY0zDqCr for ; Sat, 25 Jun 2016 02:28:25 +1000 (AEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP; 24 Jun 2016 09:28:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.26,521,1459839600"; d="scan'208"; a="1009009512" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga002.fm.intel.com with ESMTP; 24 Jun 2016 09:28:22 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id u5OGSKgP019685; Fri, 24 Jun 2016 17:28:20 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id u5OGSK3D006880; Fri, 24 Jun 2016 17:28:20 +0100 Received: (from sfinucan@localhost) by sivswdev01.ir.intel.com with id u5OGSKbR006876; Fri, 24 Jun 2016 17:28:20 +0100 From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH 2/5] models: Return string from 'combined_check_status' Date: Fri, 24 Jun 2016 17:28:13 +0100 Message-Id: <1466785696-6822-2-git-send-email-stephen.finucane@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1466785696-6822-1-git-send-email-stephen.finucane@intel.com> References: <1466785696-6822-1-git-send-email-stephen.finucane@intel.com> X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.22 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" Previously the 'combined_check_status' function returned the checks enum integer for the status field. However, the string representation is more meaningful and is the only representation seen by users at moment. Change this function so it returns, for example, 'success' instead of '1'. Signed-off-by: Stephen Finucane Reviewed-by: Andy Doan --- patchwork/models.py | 7 ++++--- patchwork/tests/test_checks.py | 4 +++- patchwork/views/xmlrpc.py | 4 +--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/patchwork/models.py b/patchwork/models.py index 3141da2..4d92db3 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -399,17 +399,18 @@ class Patch(Submission): * success, if latest checks for all contexts reports as success """ + state_names = dict(Check.STATE_CHOICES) states = [check.state for check in self.checks] if not states: - return Check.STATE_PENDING + return state_names[Check.STATE_PENDING] for state in [Check.STATE_FAIL, Check.STATE_WARNING, Check.STATE_PENDING]: # order sensitive if state in states: - return state + return state_names[state] - return Check.STATE_SUCCESS + return state_names[Check.STATE_SUCCESS] @property def checks(self): diff --git a/patchwork/tests/test_checks.py b/patchwork/tests/test_checks.py index 85c02c1..d7b8a25 100644 --- a/patchwork/tests/test_checks.py +++ b/patchwork/tests/test_checks.py @@ -60,7 +60,9 @@ class PatchChecksTest(TransactionTestCase): return check def assertCheckEqual(self, patch, check_state): - self.assertEqual(self.patch.combined_check_state, check_state) + state_names = dict(Check.STATE_CHOICES) + self.assertEqual(self.patch.combined_check_state, + state_names[check_state]) def assertChecksEqual(self, patch, checks=None): if not checks: diff --git a/patchwork/views/xmlrpc.py b/patchwork/views/xmlrpc.py index 1f48959..638b3b1 100644 --- a/patchwork/views/xmlrpc.py +++ b/patchwork/views/xmlrpc.py @@ -353,10 +353,8 @@ def check_to_dict(obj): def patch_check_to_dict(obj): """Return a combined patch check.""" - state_names = dict(Check.STATE_CHOICES) - return { - 'state': state_names[obj.combined_check_state], + 'state': obj.combined_check_state, 'total': len(obj.checks), 'checks': [check_to_dict(check) for check in obj.checks] }