From nobody Wed May 14 16:01:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1534581753626423.8108722407728; Sat, 18 Aug 2018 01:42:33 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 532F65D691; Sat, 18 Aug 2018 08:42:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 43783951DB; Sat, 18 Aug 2018 08:42:32 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 350804A460; Sat, 18 Aug 2018 08:42:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7I8duLd013244 for ; Sat, 18 Aug 2018 04:39:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 489883091323; Sat, 18 Aug 2018 08:39:56 +0000 (UTC) Received: from mx1.redhat.com (ext-mx17.extmail.prod.ext.phx2.redhat.com [10.5.110.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4121E309128B for ; Sat, 18 Aug 2018 08:39:54 +0000 (UTC) Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com [74.125.82.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6E3943082DD4 for ; Sat, 18 Aug 2018 08:39:53 +0000 (UTC) Received: by mail-wm0-f52.google.com with SMTP id i134-v6so3076032wmf.0 for ; Sat, 18 Aug 2018 01:39:53 -0700 (PDT) Received: from donizetti.lan (dynamic-adsl-78-12-184-244.clienti.tiscali.it. [78.12.184.244]) by smtp.gmail.com with ESMTPSA id j39-v6sm4830677wre.44.2018.08.18.01.39.51 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 18 Aug 2018 01:39:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=sgwU6plkfp8tyWtmbhkZ43DZJsiBnfRqhGQh8tXFyXA=; b=fm5VuVlQquMLbwUJrDp7SiQkw9XWYuvLH9/Px3apTK8DjXy1dVujGmFtvuuSBiSrCe Co53W1y2u63NSglB1fOO2MPDvRievyYWAmqRJGqm9YNJ6C0gnqxevhy3CUsEwyLl5WHe AL7r4uyJD26A65b5JkwMuZNnIWBqY73DFRlPCNt0W/MPMY2KnLn1mkF/HzaX2d9ajNl3 wZS22HsoQ7holZELOw6W30Sg74gAv/tgnfIek2qszOtVB8nXvHqj7Qg7ktINuGPLGmfu HPdBT82iUZT1hWCP+EtIgN4NM5B2tWILMvBgoPJk7/uRW4VUau4sVjTJNt7RLybGlzd2 3bNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=sgwU6plkfp8tyWtmbhkZ43DZJsiBnfRqhGQh8tXFyXA=; b=Sku5DhEyhu1PmtSKWDDeRchX3ieE4RGvEQfVnY3yOWhrxPXwkThKPNFLBcLb2hnJwt 7zzkAuDWtxq+S3/KPSd9Hqo/2MDzHhs+HyDDafUm37LgFLglBpaXilxq3b2hHhULz7Yi np7517Ia01ihH1Mog2Srco/OGDRG5Ld2jW/82PVx4vVvwoqYF9WpV9jQR3c5XpbrzOJ/ Yv79N133F8b26gZnmQCCLvTKARmMl4N89BOFaF20ZeIW34oyfG7W6AxNVS8VlJig+8te kGwiFTg0QBDG6f1YnbAdD36/RjTwyB7AUDDeyZhCYSwQk//rQCQUhMPkJE0ziqnydSVO GZZQ== X-Gm-Message-State: AOUpUlEz4OJouNm8UnFb0UXFwi45i7GzH3FDnK3ivsAplaeVpuU3NDQ8 SaoIa5NjYn4Yrxpetay2dZN8cBOF X-Google-Smtp-Source: AA+uWPxMji1ZS61wEbZOvI7OvJldqcRXw3bM1VaGLXs3b40kJRm9au6M4fJujCDl+JT1ZlKH3NyBKg== X-Received: by 2002:a1c:e708:: with SMTP id e8-v6mr21233624wmh.134.1534581591933; Sat, 18 Aug 2018 01:39:51 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Sat, 18 Aug 2018 10:39:41 +0200 Message-Id: <20180818083944.19692-7-pbonzini@redhat.com> In-Reply-To: <20180818083944.19692-1-pbonzini@redhat.com> References: <20180818083944.19692-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Sat, 18 Aug 2018 08:39:53 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Sat, 18 Aug 2018 08:39:53 +0000 (UTC) for IP:'74.125.82.52' DOMAIN:'mail-wm0-f52.google.com' HELO:'mail-wm0-f52.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.028 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 74.125.82.52 mail-wm0-f52.google.com 74.125.82.52 mail-wm0-f52.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.84 on 10.5.110.46 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 6/9] rest: fix get_serializer_context for /projects/ID/{messages, series} X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Sat, 18 Aug 2018 08:42:32 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_0 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" A raise was exchanged with return here, so that a 404 was not reported. In addition, for cleanliness, base the context on the superclass implementation so that format and view are included in the context. Signed-off-by: Paolo Bonzini --- api/rest.py | 6 ++++-- tests/test_rest.py | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/api/rest.py b/api/rest.py index 2b0b611..df0640a 100644 --- a/api/rest.py +++ b/api/rest.py @@ -251,8 +251,10 @@ class ProjectMessagesViewSetMixin(mixins.RetrieveModel= Mixin): =20 def get_serializer_context(self): if self.project is None: - return Http404 - return {'project': self.project, 'request': self.request} + raise Http404 + context =3D super(ProjectMessagesViewSetMixin, self).get_serialize= r_context() + context['project'] =3D self.project + return context =20 # Series =20 diff --git a/tests/test_rest.py b/tests/test_rest.py index 980d61a..7b035bc 100755 --- a/tests/test_rest.py +++ b/tests/test_rest.py @@ -230,7 +230,7 @@ class RestTest(PatchewTestCase): self.assertEqual(resp.data['count'], 2) =20 resp =3D self.api_client.get(self.REST_BASE + 'projects/12345/seri= es/') - self.assertEqual(resp.data['count'], 0) + self.assertEqual(resp.status_code, 404) =20 def test_series_results_list(self): resp1 =3D self.apply_and_retrieve('0001-simple-patch.mbox.gz', @@ -263,9 +263,9 @@ class RestTest(PatchewTestCase): self.assertEqual('patches' in resp.data['results'][1], False) =20 resp =3D self.api_client.get(self.REST_BASE + 'projects/12345/seri= es/?q=3Dquorum') - self.assertEqual(resp.data['count'], 0) + self.assertEqual(resp.status_code, 404) resp =3D self.api_client.get(self.REST_BASE + 'projects/12345/seri= es/?q=3Dproject:QEMU') - self.assertEqual(resp.data['count'], 0) + self.assertEqual(resp.status_code, 404) =20 def test_series_delete(self): test_message_id =3D '1469192015-16487-1-git-send-email-berrange@re= dhat.com' --=20 2.17.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel