From nobody Tue May 13 19:36:43 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 1534601449358857.7605270234353; Sat, 18 Aug 2018 07:10:49 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 15D26C057FA6; Sat, 18 Aug 2018 14:10:48 +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 05D1D100191B; Sat, 18 Aug 2018 14:10:48 +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 EF51F4A465; Sat, 18 Aug 2018 14:10:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7IEAkpg020465 for ; Sat, 18 Aug 2018 10:10:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id E5A535E7D1; Sat, 18 Aug 2018 14:10:46 +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 DC69B17CE2 for ; Sat, 18 Aug 2018 14:10:43 +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 A73C43082E06 for ; Sat, 18 Aug 2018 14:10:42 +0000 (UTC) Received: by mail-wm0-f52.google.com with SMTP id y2-v6so10080817wma.1 for ; Sat, 18 Aug 2018 07:10:42 -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 g2-v6sm13874652wrd.71.2018.08.18.07.10.40 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 18 Aug 2018 07:10:40 -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=b+5ul3qFtSo2bFl90QZGMJdvzj+9c8Zsx+tNnre9klYU6NUe1Z1rOHRGNjhmEVk4Z8 aev+p4DKvhItHrWm/qjAOOtLjWv+xeZWiTEreWdaHB3ML9w+Hkdpk6o76UwiQnqV5KwR nxlL9OaJXKy3zsVJdF9EJzyG1MJOUm9ssoWZugcVr5dxxtZl9qbNXax2CWHPyT/UQPMB R8nmfuz5gXRVCCHhDJScIEHB8rmiXWdnAw5uqhoh1U1yOjibxfWTYTpq/vuZTd7T/t4g DisF7sv+VvLQ3zVqedekt5JjZO81Y8a80Lj2CMTQsF0jWhqpgKQWtmCLMUajmYkbNaal y6lQ== 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=JvCxkMgm7PWZHsOTh4oi9URu+MqKe21uOCju5uY6osmNw8oUoz0WQPdxBD8LEhHa7d lidgOyjoK9HRSSBuRcu34Bjb9rN+sc1sk4+Pv/QPXe8DljFMmKRw5kiM1gg4zyOqWDAM ydZd+xn2+pv6XYUmsB9GCMOoR9Ls9qVbpOXS+4NEmLpw0xRuB6jjzA5zyGgC8viOUVMg JNzRozujj0OQyg+Z11xMq9Amsqb2+D2f5oYYJcYQnUfkxhnmDXwgFD4Mw05IwhtAPz0J JvUjo4kTYzEyg4UrabXjhiiFAJrxizdSeiLCg56Jt2DCEhK/XgncvLC0Xf5JAyV9YdV/ Hxsw== X-Gm-Message-State: AOUpUlF5dmRGqFYRn3My8vGnccmuLEWFKvxJAa4KOoSgp5PPluUmgIfh GkCzQ74IC4BgS3vM1TqrdBzjAJB+ X-Google-Smtp-Source: AA+uWPwdVfJhOKD60oFQKbkepAz86LZFGQU6/Ya+HV/lMKuxygJjoulEob1dgvCGHo8vuVmMh1rdqg== X-Received: by 2002:a1c:9290:: with SMTP id u138-v6mr22711199wmd.52.1534601441114; Sat, 18 Aug 2018 07:10:41 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Sat, 18 Aug 2018 16:10:30 +0200 Message-Id: <20180818141033.29752-7-pbonzini@redhat.com> In-Reply-To: <20180818141033.29752-1-pbonzini@redhat.com> References: <20180818141033.29752-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 14:10:42 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Sat, 18 Aug 2018 14:10:42 +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.79 on 10.5.11.14 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Sat, 18 Aug 2018 14:10:48 +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