From nobody Wed May 14 16:03:45 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 15345815964891020.3451640947484; Sat, 18 Aug 2018 01:39:56 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E64BD81DE7; Sat, 18 Aug 2018 08:39:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D2ED016C04; Sat, 18 Aug 2018 08:39:54 +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 C5389180613A; Sat, 18 Aug 2018 08:39:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7I8dr6j013213 for ; Sat, 18 Aug 2018 04:39:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8121262460; Sat, 18 Aug 2018 08:39:53 +0000 (UTC) Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 77EDE61F4F for ; Sat, 18 Aug 2018 08:39:51 +0000 (UTC) Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com [74.125.82.48]) (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 6228D3084216 for ; Sat, 18 Aug 2018 08:39:50 +0000 (UTC) Received: by mail-wm0-f48.google.com with SMTP id q8-v6so9333883wmq.4 for ; Sat, 18 Aug 2018 01:39:50 -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.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 18 Aug 2018 01:39:48 -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=qo9nUVUE0DxTq4vgMwBHWbHXYOMFFvsK+wMNRdkY+TM=; b=hiXh8c2v+KJEJHtbgUpn9SRHDySyNkHervqsEe848lbFRJWh5Rk6ZzDPESuVta5z9o NmirEtbbNkCzU9JrLGjzvmQ95BPKpInzn/0CxK/ipW4JUWAIbrSdljoF0fUTegKfXYg6 eUBme9ZOsG7Q5KK76qsatDg/vt+4fWUjtWv1YfE2SN8pA/Oy6CpBmy+3vyQKxZbAe9Qp NucXnGOi87OZtsx7FfWP9mu4EEH1iH9mwqu9uyoc+SxNNCvgSCdyLWgK2+syao/Kvu2n KKEQbN2fFyMYygR5PQP85RP7vU7CZiZofuc9cjLWpk+DL1LaA5lRZqHQvrKx121ndBKk VmhQ== 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=qo9nUVUE0DxTq4vgMwBHWbHXYOMFFvsK+wMNRdkY+TM=; b=CEmvAoTJWcHvjxUqjIOSpAsu2yIlZelOQKAaM4Mhzf0KLsXnqmnTp+RgbSKvqGP+SO cFuOeqvW0hUlXzgYQLwoYIr8MLcFpKKoeMqCW41d2bFDwCknX+44krb6gV/IRj5KmgNp NuXgA8q5e5+lfod9DD4xKWbnfswpPYB0L0BhvI0zTfm2wyrbcEiBeP23suF87hhAkgqT S4eTs4Fu6qpEWJBwtp5CwMWWVkwwPNbIIulJNA1WlaU4psZ+h5dnWyw5sb8yYywSeMXJ tUWocQtTbGd7THU3e6Wt3vGekaqjku9Nl4g0cv4PilDDoS/ge4Ew94bpDoIvxZN0B2RU hrmw== X-Gm-Message-State: AOUpUlEig4pdMpKbpnBeQXt2fDD94Y29UllccWBk5+OQpDj9v0lDOzKy 03zyo/VnISYaerWguM0MAOcIsUI4 X-Google-Smtp-Source: AA+uWPy6T8AYoUze45LefDSPA2gM5sHsPaTqEEbmg1/hZD9AxuRKMrrj7IR/ExCwNlkGD1MrirTX4Q== X-Received: by 2002:a1c:9cd3:: with SMTP id f202-v6mr20444542wme.148.1534581588875; Sat, 18 Aug 2018 01:39:48 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Sat, 18 Aug 2018 10:39:38 +0200 Message-Id: <20180818083944.19692-4-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.40]); Sat, 18 Aug 2018 08:39:50 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Sat, 18 Aug 2018 08:39:50 +0000 (UTC) for IP:'74.125.82.48' DOMAIN:'mail-wm0-f48.google.com' HELO:'mail-wm0-f48.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.48 mail-wm0-f48.google.com 74.125.82.48 mail-wm0-f48.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.84 on 10.5.110.40 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 3/9] testing: include result URI in testing-get API response 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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Sat, 18 Aug 2018 08:39:54 +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" This is simpler to use than the "identity" field, if patchew-cli is going to use a PUT request to the REST API instead of testing-report. Signed-off-by: Paolo Bonzini --- api/rest.py | 28 ++++++++++++++++++++++++++++ mods/testing.py | 16 ++++++++++------ 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/api/rest.py b/api/rest.py index 9ec0ae8..bd46211 100644 --- a/api/rest.py +++ b/api/rest.py @@ -77,6 +77,34 @@ class PatchewPermission(permissions.BasePermission): class ImportPermission(PatchewPermission): allowed_groups =3D ('importers',) =20 +# utility function to generate REST API URLs + +def reverse_detail(obj, request): + if isinstance(obj, Project): + return rest_framework.reverse.reverse("project-detail", + request=3Drequest, + kwargs=3D{"pk": obj.id}) + if isinstance(obj, Message): + assert obj.is_series_head + return rest_framework.reverse.reverse("series-detail", + request=3Drequest, + kwargs=3D{"projects_pk": obj= .project.id, + "message_id": obj.me= ssage_id}) + if isinstance(obj, ProjectResult): + po =3D obj.obj + return rest_framework.reverse.reverse("results-detail", + request=3Drequest, + kwargs=3D{"projects_pk": po.= id, + "name": obj.name}) + if isinstance(obj, MessageResult): + m =3D obj.obj + return rest_framework.reverse.reverse("results-detail", + request=3Drequest, + kwargs=3D{"projects_pk": m.p= roject.id, + "series_message_id":= m.message_id, + "name": obj.name}), + raise Error("unhandled object type") + # pluggable field for plugin support =20 class PluginMethodField(SerializerMethodField): diff --git a/mods/testing.py b/mods/testing.py index 0266fb9..ecd63d1 100644 --- a/mods/testing.py +++ b/mods/testing.py @@ -20,6 +20,7 @@ import math from api.views import APILoginRequiredView from api.models import (Message, MessageProperty, MessageResult, Project, ProjectResult, Result) +from api.rest import reverse_detail from api.search import SearchEngine from event import emit_event, declare_event, register_handler from patchew.logviewer import LogView @@ -388,17 +389,18 @@ class TestingGetView(APILoginRequiredView): name =3D "testing-get" allowed_groups =3D ["testers"] =20 - def _generate_test_data(self, project, repo, head, base, identity, tes= t): + def _generate_test_data(self, project, repo, head, base, identity, res= ult_uri, test): r =3D {"project": project, "repo": repo, "head": head, "base": base, "test": test, - "identity": identity + "identity": identity, + "result_uri": result_uri, } return r =20 - def _generate_series_test_data(self, s, test): + def _generate_series_test_data(self, request, s, result, test): gr =3D s.git_result assert gr.is_success() return self._generate_test_data(project=3Ds.project.name, @@ -410,15 +412,17 @@ class TestingGetView(APILoginRequiredView): "message-id": s.message_id, "subject": s.subject, }, + result_uri=3Dreverse_detail(result= , request), test=3Dtest) =20 - def _generate_project_test_data(self, project, repo, head, base, test): + def _generate_project_test_data(self, request, project, repo, head, ba= se, result, test): return self._generate_test_data(project=3Dproject, repo=3Drepo, head=3Dhead, base=3Db= ase, identity=3D{ "type": "project", "head": head, }, + result_uri=3Dreverse_detail(result= , request), test=3Dtest) =20 def _find_applicable_test(self, queryset, user, po, tester, capabiliti= es): @@ -448,7 +452,7 @@ class TestingGetView(APILoginRequiredView): candidates =3D self._find_applicable_test(ProjectResult.objects.fi= lter(project=3Dpo), request.user, po, tester, = capabilities) for r, test in candidates: - td =3D self._generate_project_test_data(po.name, repo, head, t= ested, test) + td =3D self._generate_project_test_data(request, po.name, repo= , head, tested, r, test) return r, po, td return None =20 @@ -457,7 +461,7 @@ class TestingGetView(APILoginRequiredView): request.user, po, tester, = capabilities) for r, test in candidates: s =3D r.message - td =3D self._generate_series_test_data(s, test) + td =3D self._generate_series_test_data(request, s, r, test) return r, s, td return None =20 --=20 2.17.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel