From nobody Fri Apr 26 01:38:17 2024 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 1521298047002269.16779262513967; Sat, 17 Mar 2018 07:47:27 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 14C84C0587C2; Sat, 17 Mar 2018 14:47:26 +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 010167EE12; Sat, 17 Mar 2018 14:47:26 +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 E76A01808800; Sat, 17 Mar 2018 14:47:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2HElPOZ007051 for ; Sat, 17 Mar 2018 10:47:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4017A80F65; Sat, 17 Mar 2018 14:47:25 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 39A5280F60 for ; Sat, 17 Mar 2018 14:47:22 +0000 (UTC) Received: from mail-wr0-f175.google.com (mail-wr0-f175.google.com [209.85.128.175]) (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 C1984C04BE24 for ; Sat, 17 Mar 2018 14:47:19 +0000 (UTC) Received: by mail-wr0-f175.google.com with SMTP id o8so14384628wra.1 for ; Sat, 17 Mar 2018 07:47:19 -0700 (PDT) Received: from donizetti.lan (94-36-191-219.adsl-ull.clienti.tiscali.it. [94.36.191.219]) by smtp.gmail.com with ESMTPSA id p12sm7724855wre.89.2018.03.17.07.47.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 17 Mar 2018 07:47:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=8wXKwZfJAgXvPK8c3eTM79EKnFxJur7wsNKXjl5dwJI=; b=Ly3Tv3PthIlTQelzNcNubWIDNe+sWEHfSqxrRPYdalR/pi42rJuH/HRt3Cro/KyTQ1 h5QmEnXxjhfLaSuVYbNDyMFPMPcRg+3B1B37OqNDHlg8e4ErPQjPly5yqMQlBkcUJi5n XmwgaAkQAGTd+8L0fTuDRkTY07PgnnQ09pdDaOFGpaeI+Qh3EmoqXj/Wr5Q1FWQWDZpw gM9hZDYKecp5yWu8V9v6T8DBJYE/nGLYzRAi4RubHOIXlhLkFR6T6b9E6ZHdFOmxCp8c esNN2qkWTdopRCPa0+L3DZJzm81PG4qsOWhuFn3einLLdZ2XeqRQyePx2FbsEdJ3q1Fu Q1zA== 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:cc:subject:date:message-id :in-reply-to:references; bh=8wXKwZfJAgXvPK8c3eTM79EKnFxJur7wsNKXjl5dwJI=; b=V7yj8+sgqHI1Nf4qr65OD8B0HryZnLpy1M+s7iiKdmxhROeT52B++CsfAWScdSYzxY NVykQ8QFm5eWd+6ilzHRyvfB1HhLGw4dnh57a89PBDLKnJ3B9G7OkKEOonBkgSylB4gS 2bqz6cw008S1ywN+dNtLL8ANlgYPsRQcuHWxj2H//trI1sSgDjQGcCUj4nHuoLXIlJpk Rer6hk9ZavSB8DVCxDqoAlFxLG6iGj78IR/qmwvrkZEO7FQgSlNEl9R0V5HNWShY+wdg rz3RhxSO5wrBFItC4r9X1shdAjx+A6fCtuqFols9+IKnUDjLJB5qp3gQlGjubLIF/HOX kfkQ== X-Gm-Message-State: AElRT7Hne7shuJEoHyeooGt/8Z3LhxhSAuOxZXORLpjFg42UbVOuJ/Sa /nPe64NhWwrtTBszDfg+stv3ct3X X-Google-Smtp-Source: AG47ELtD38Ay+ApDCEmo6EnJPIrAI5Q8rwCZmQQ/A17jmqzOnoLpO7KiQNweAsxgz4YYoXP0aNRftw== X-Received: by 10.223.138.138 with SMTP id y10mr4270104wry.44.1521298036882; Sat, 17 Mar 2018 07:47:16 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Sat, 17 Mar 2018 15:47:10 +0100 Message-Id: <20180317144714.18268-2-pbonzini@redhat.com> In-Reply-To: <20180317144714.18268-1-pbonzini@redhat.com> References: <20180317144714.18268-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sat, 17 Mar 2018 14:47:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sat, 17 Mar 2018 14:47:19 +0000 (UTC) for IP:'209.85.128.175' DOMAIN:'mail-wr0-f175.google.com' HELO:'mail-wr0-f175.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.487 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.128.175 mail-wr0-f175.google.com 209.85.128.175 mail-wr0-f175.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: patchew-devel@redhat.com Cc: Shubham Jain Subject: [Patchew-devel] [PATCH 1/5] git: include absolute link to log in REST result 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.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Sat, 17 Mar 2018 14:47:26 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Links in the REST API should be absolute. The next patch will centralize this in the Result object, in the meanwhile fix the git plugin. Signed-off-by: Paolo Bonzini --- mods/git.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/git.py b/mods/git.py index 4fd7dbe..69b5da8 100644 --- a/mods/git.py +++ b/mods/git.py @@ -123,8 +123,8 @@ class GitModule(PatchewModule): git_tag =3D message.get_property("git.tag") data =3D {'repo': git_repo, 'tag': 'refs/tags/' + git_tag} result =3D {'status': 'success', 'data': data} - result['log_url'] =3D reverse("git-log", - kwargs=3D{'series': message.messag= e_id}) + log_url =3D reverse("git-log", kwargs=3D{'series': message.mes= sage_id}) + result['log_url'] =3D request.build_absolute_uri(log_url) else: result =3D {'status': 'pending'} results['git'] =3D result --=20 2.16.2 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Fri Apr 26 01:38:17 2024 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 1521298047189783.9360305517343; Sat, 17 Mar 2018 07:47:27 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 41B538553D; Sat, 17 Mar 2018 14:47:26 +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 35D4E600C8; Sat, 17 Mar 2018 14:47:26 +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 2C15E1808800; Sat, 17 Mar 2018 14:47:26 +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 w2HElO4o007044 for ; Sat, 17 Mar 2018 10:47:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9AF805D734; Sat, 17 Mar 2018 14:47:24 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 933EC5D729 for ; Sat, 17 Mar 2018 14:47:21 +0000 (UTC) Received: from mail-wr0-f175.google.com (mail-wr0-f175.google.com [209.85.128.175]) (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 4758680F98 for ; Sat, 17 Mar 2018 14:47:20 +0000 (UTC) Received: by mail-wr0-f175.google.com with SMTP id z73so10082493wrb.0 for ; Sat, 17 Mar 2018 07:47:20 -0700 (PDT) Received: from donizetti.lan (94-36-191-219.adsl-ull.clienti.tiscali.it. [94.36.191.219]) by smtp.gmail.com with ESMTPSA id p12sm7724855wre.89.2018.03.17.07.47.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 17 Mar 2018 07:47:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=5gawAcMG7XD4i+wNPnp5Xhq8AfOuQgn7SRtsvGJyoUo=; b=DAzbiZH8vaGe+rTd0DIKk4y7pDyhsP1PPV/Vz/yRLmK4yvN3gWl1UZlqCceEuWO3NH GcbhgG7O6Z1ePwYvkTZ/V3+W89cJkdlIt1E8dn4IGn7KwaE38/51m4cPK3MK2uy1Mdfq 6hktr7/Iupt/owbDJRYzeuUFq4OLKphgHG32bgsC0xDcJBgF+MHdv5owSxP2Nl9XY3Qc jFp8sc6KY0tvlIYJZz9wjkcV1FhQ2XzmJldQWtsxJtIASpPg54UjlKwIqvTyZbUc73qY z/zJBs6ZHExGu9KhvkIdY1Hh8zc+e52W37cDuCOPZ3aZDErcmB2lnzf0M8shqW6515R5 aegw== 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:cc:subject:date:message-id :in-reply-to:references; bh=5gawAcMG7XD4i+wNPnp5Xhq8AfOuQgn7SRtsvGJyoUo=; b=O+X/0EpWQb+x86hsuZB9s9BEwd2cY4z1AvhE/hm455sGsmYrPVayaQFrpiDVVRsyW4 j5I+xXE+8EiuKk3HG6RuuzAc+DNmbCIntYIHHMrAWNB9uUa3Fz0nCCy/yV/sWqMD3Sow /vndJ+Y39Hh/o+CAxhroaOagSG0UeNc685Fxa1g12IlXA4TpG7fyM7Cv+/Ri3GvxTVQ5 BdgXTt0lAWkkvEBiYe7vw1TsKYlenifKcdUQw2qp9u0nSJbdWk7TtkApaMoMQTYW8qQV F30Y3aD4OqMHfrqUMWO4RDXqLizZcDB5QRwpm05huzV6hWIcWKnRXXPcwbfq8/UfKZj6 MD3Q== X-Gm-Message-State: AElRT7Htvr+hGXLmQkfYcXb6osCYKF9mO1i/wBimIwkaW30oHSsKRo2Y mDZaGBVQdKjrbJfSxQSl8K96twhr X-Google-Smtp-Source: AG47ELtzWSw/G/zdRDabWSOYh1/k+pKB2XoRpP3LSq7zQ/3T6caaKsWnQAaoSkdMDuy3EEM0Idxy5A== X-Received: by 10.223.196.212 with SMTP id o20mr4561663wrf.144.1521298038192; Sat, 17 Mar 2018 07:47:18 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Sat, 17 Mar 2018 15:47:11 +0100 Message-Id: <20180317144714.18268-3-pbonzini@redhat.com> In-Reply-To: <20180317144714.18268-1-pbonzini@redhat.com> References: <20180317144714.18268-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sat, 17 Mar 2018 14:47:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sat, 17 Mar 2018 14:47:20 +0000 (UTC) for IP:'209.85.128.175' DOMAIN:'mail-wr0-f175.google.com' HELO:'mail-wr0-f175.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.487 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.128.175 mail-wr0-f175.google.com 209.85.128.175 mail-wr0-f175.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: patchew-devel@redhat.com Cc: Shubham Jain Subject: [Patchew-devel] [PATCH 2/5] rest: create Result object 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.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Sat, 17 Mar 2018 14:47:26 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Result objects were introduced first in the REST API. As a first step towards making them a first-class model, let rest_results_hook return Result namedtuples. Even though for now they are just converted back to a dictionary in the get_results method, they will get their own serializer later. Signed-off-by: Paolo Bonzini --- api/rest.py | 17 +++++++++++++++-- mods/git.py | 13 ++++++++----- mods/testing.py | 8 +++----- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/api/rest.py b/api/rest.py index 7c131a4..0bb3c30 100644 --- a/api/rest.py +++ b/api/rest.py @@ -8,6 +8,8 @@ # This work is licensed under the MIT License. Please see the LICENSE fil= e or # http://opensource.org/licenses/MIT. =20 +from collections import namedtuple + from django.contrib.auth.models import User from django.template import loader =20 @@ -140,6 +142,17 @@ class ProjectMessagesViewSetMixin(mixins.RetrieveModel= Mixin): def get_queryset(self): return self.queryset.filter(project=3Dself.kwargs['projects_pk']) =20 +class Result(namedtuple("Result", "name status log_url data")): + __slots__ =3D () + + def __new__(cls, name, status, log_url=3DNone, data=3DNone, request=3D= None): + if log_url is not None and request is not None: + log_url =3D request.build_absolute_uri(log_url) + if status not in ('pending', 'success', 'failure'): + raise ValueError("invalid value '%s' for status field" % statu= s) + return super(cls, Result).__new__(cls, status=3Dstatus, log_url=3D= log_url, + data=3Ddata, name=3Dname) + # Series =20 class ReplySerializer(BaseMessageSerializer): @@ -177,11 +190,11 @@ class SeriesSerializer(BaseMessageSerializer): return fields =20 def get_results(self, message): - results =3D {} + results =3D [] request =3D self.context['request'] dispatch_module_hook("rest_results_hook", request=3Drequest, message=3Dmessage, results=3Dresults) - return results + return {x.name: x._asdict() for x in results} =20 def get_total_patches(self, obj): return obj.get_total_patches() diff --git a/mods/git.py b/mods/git.py index 69b5da8..fc71174 100644 --- a/mods/git.py +++ b/mods/git.py @@ -21,6 +21,7 @@ from django.utils.html import format_html from mod import PatchewModule from event import declare_event, register_handler, emit_event from api.models import Project, Message, MessageProperty +from api.rest import Result from api.views import APILoginRequiredView, prepare_series from patchew.logviewer import LogView from schema import * @@ -115,19 +116,21 @@ class GitModule(PatchewModule): =20 def rest_results_hook(self, request, message, results): l =3D message.get_property("git.apply-log") + data =3D None if l: if message.get_property("git.apply-failed"): - result =3D {'status' : 'failure'} + status =3D 'failure' else: git_repo =3D message.get_property("git.repo") git_tag =3D message.get_property("git.tag") data =3D {'repo': git_repo, 'tag': 'refs/tags/' + git_tag} - result =3D {'status': 'success', 'data': data} + status =3D 'success' log_url =3D reverse("git-log", kwargs=3D{'series': message.mes= sage_id}) - result['log_url'] =3D request.build_absolute_uri(log_url) else: - result =3D {'status': 'pending'} - results['git'] =3D result + status =3D 'pending' + log_url =3D None + results.append(Result(name=3D'git', status=3Dstatus, log_url=3Dlog= _url, data=3Ddata, + request=3Drequest)) =20 def prepare_message_hook(self, request, message, detailed): if not message.is_series_head: diff --git a/mods/testing.py b/mods/testing.py index 24bd509..970256d 100644 --- a/mods/testing.py +++ b/mods/testing.py @@ -20,6 +20,7 @@ import smtplib import email import traceback import math +from api.rest import Result from api.views import APILoginRequiredView from api.models import Message, Project, MessageProperty from api.search import SearchEngine @@ -289,11 +290,8 @@ class TestingModule(PatchewModule): failed =3D not p["passed"] log_url =3D self.reverse_testing_log(message, tn, request=3Dre= quest, html=3DFalse) passed_str =3D "failure" if failed else "success" - result =3D { - 'status': passed_str, - 'log_url': log_url - } - results['testing.' + tn] =3D result + results.append(Result(name=3D'testing.' + tn, status=3Dpassed_= str, log_url=3Dlog_url, + request=3Drequest)) =20 def prepare_message_hook(self, request, message, detailed): if not message.is_series_head: --=20 2.16.2 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Fri Apr 26 01:38:17 2024 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 1521298048989352.664869319652; Sat, 17 Mar 2018 07:47:28 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1805E4E4C6; Sat, 17 Mar 2018 14:47:28 +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 0BDE360BE7; Sat, 17 Mar 2018 14:47:28 +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 033EA4CA98; Sat, 17 Mar 2018 14:47:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2HElQBw007071 for ; Sat, 17 Mar 2018 10:47:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8192F183CE; Sat, 17 Mar 2018 14:47:26 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7B59860BE7 for ; Sat, 17 Mar 2018 14:47:23 +0000 (UTC) Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) (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 C02F7C04AC45 for ; Sat, 17 Mar 2018 14:47:22 +0000 (UTC) Received: by mail-wr0-f196.google.com with SMTP id s10so1487581wra.13 for ; Sat, 17 Mar 2018 07:47:22 -0700 (PDT) Received: from donizetti.lan (94-36-191-219.adsl-ull.clienti.tiscali.it. [94.36.191.219]) by smtp.gmail.com with ESMTPSA id p12sm7724855wre.89.2018.03.17.07.47.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 17 Mar 2018 07:47:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=BvB8HeZ11h6rD4WdSFJBCpl6RWPHe9Tos0Ek+Q7dI/Q=; b=KBPQw25P54v3+PED+04Rm1UuGvy3reJhOuBH8qQjQ5l3ceSydDE9l8e5uiGhQ2DoW+ kRFWgHR92+6p9Z7k4GC/I/w0vh+/+lB98QkhQR1IJ/JkLvrP8buN1GG9jIo97ZjypGXY ieyVxfB3m0GBvVw/Ul42oZzrgZwPe/oBSDm28IO8viSbF5yWyL9UPPVcZM7yjZhc9NOY xI9p1a902f5885gvKvdhi1vlzMMKsHkuXzXRI2I8e6MFkXabd/fRGwAyd2gM8sR/r5Tb b1LXfXBWR18REJCS4xg0i5YKeOPV+f6UQGnNnO5HIzwXF7MseKFkOqhZ0b/q4D2iyhf2 6xGA== 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:cc:subject:date:message-id :in-reply-to:references; bh=BvB8HeZ11h6rD4WdSFJBCpl6RWPHe9Tos0Ek+Q7dI/Q=; b=jO/TqAHoRFfXfF+hZ8Lyroarme1Uz8uyHbX9RwLc1kwA6ox9ll6uN9zvJx/LnFuwTu xo0TKpokV1TJTLwlQGzKk+q04A9F54MkfXsfkovm8/CRGGPQL6Fjsrp20AQd+sa/4yDF LLD6/hH1BKDpgB0WEUsEz5Dx916yYo1HihoRLk/se4TW9t1CD8Z30eWLLJEmXGvvo+Nl 6CfElNg8xvyHV02eYIN57oxkg9tvDS6d6L81QgUHLMb4sOYC166IH+Xm4Qz9qpOC6vgd O6euBuwexOsVljDoOxi8GnvMoXTDt1wYnJJkm69MoPWAX/QOr0MJ2JhQJOV7L4+ogiB4 DsFA== X-Gm-Message-State: AElRT7EZqP3F9w5EuOtJmLWzco4sOhrjNEHXCcOsqCSz+y5VQxgp8d6Z UrtT0NgQ9mfmpSCTVC8cMVYoYt8F X-Google-Smtp-Source: AG47ELveEZoCYZnVG+Zw4PaDxniy0T+JbIF+UQubg8oF/Wg760hzXJq/SqCo9n7Se2pluwRQJhstUg== X-Received: by 10.223.226.14 with SMTP id j14mr4480753wri.17.1521298041122; Sat, 17 Mar 2018 07:47:21 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Sat, 17 Mar 2018 15:47:12 +0100 Message-Id: <20180317144714.18268-4-pbonzini@redhat.com> In-Reply-To: <20180317144714.18268-1-pbonzini@redhat.com> References: <20180317144714.18268-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sat, 17 Mar 2018 14:47:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sat, 17 Mar 2018 14:47:22 +0000 (UTC) for IP:'209.85.128.196' DOMAIN:'mail-wr0-f196.google.com' HELO:'mail-wr0-f196.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.487 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.128.196 mail-wr0-f196.google.com 209.85.128.196 mail-wr0-f196.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: patchew-devel@redhat.com Cc: Shubham Jain Subject: [Patchew-devel] [PATCH 3/5] rest: use lookup_field in HyperlinkedMessageField 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.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sat, 17 Mar 2018 14:47:28 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Allow overriding the lookup field, so that it can be used with views that a= re not based on BaseMessageViewSet. The next patch will use it to include the= URI for results. Signed-off-by: Paolo Bonzini --- api/rest.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/rest.py b/api/rest.py index 0bb3c30..7df7618 100644 --- a/api/rest.py +++ b/api/rest.py @@ -101,8 +101,9 @@ class ProjectsViewSet(viewsets.ModelViewSet): # Common classes for series and messages =20 class HyperlinkedMessageField(HyperlinkedIdentityField): + lookup_field =3D 'message_id' def get_url(self, obj, view_name, request, format): - kwargs =3D {'projects_pk': obj.project_id, 'message_id': obj.messa= ge_id} + kwargs =3D {'projects_pk': obj.project_id, self.lookup_field: obj.= message_id} return self.reverse(view_name, kwargs=3Dkwargs, request=3Drequest,= format=3Dformat) =20 class BaseMessageSerializer(serializers.ModelSerializer): --=20 2.16.2 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Fri Apr 26 01:38:17 2024 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 1521298055748648.3978602307159; Sat, 17 Mar 2018 07:47:35 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ADBD04E4C6; Sat, 17 Mar 2018 14:47:34 +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 A12B27EE12; Sat, 17 Mar 2018 14:47:34 +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 959244CA98; Sat, 17 Mar 2018 14:47:34 +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 w2HElXqg007100 for ; Sat, 17 Mar 2018 10:47:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6AC3E76133; Sat, 17 Mar 2018 14:47:33 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 63C2F5DD7B for ; Sat, 17 Mar 2018 14:47:33 +0000 (UTC) Received: from mail-wr0-f176.google.com (mail-wr0-f176.google.com [209.85.128.176]) (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 03FF283F45 for ; Sat, 17 Mar 2018 14:47:25 +0000 (UTC) Received: by mail-wr0-f176.google.com with SMTP id n12so14364454wra.2 for ; Sat, 17 Mar 2018 07:47:24 -0700 (PDT) Received: from donizetti.lan (94-36-191-219.adsl-ull.clienti.tiscali.it. [94.36.191.219]) by smtp.gmail.com with ESMTPSA id p12sm7724855wre.89.2018.03.17.07.47.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 17 Mar 2018 07:47:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=LfafLmNA2Uc2JfD7JK6LYz2tEdoV7Z2bvxfJVY9Jpaw=; b=Ij9Nh72D2rTlHN33zoK9UEe8FYXXfLa1cw7VL6Z8Yr/AmPjJDtiieIQJt43Q/hAyOv X3/2J+Uj8W8SzWwGrIkCZXcX16O/A7qx7f9L9T5T2doRPSwV7QfGAS/j1gPH07kc3V0Q h/3Ko/TWjc1zLYxtFQWd+jaJe4rwU0fpkaVIl2WZnVyHpLgoaphTSeTlV932Ybq1OIjU eojheTHwj3sF3yuzdPJLIs/vvyrRijSoaui4ZYIg/Brmyz3/WSZZdEjj0hU+P8DttRUp 6rsNQecoXj9y7N9JFaNfIaTt2HorDjCJqDZc8BDOumc9LDN9vd96nElEvIrIQb4+gMTu f1Uw== 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:cc:subject:date:message-id :in-reply-to:references; bh=LfafLmNA2Uc2JfD7JK6LYz2tEdoV7Z2bvxfJVY9Jpaw=; b=jUOvryL9blUW7wM8Qorc6HuUOdsJwp1Vs+dq4yvBOpSnbJS//bHKwqHdI1ExDKO/gH doJkM2f0QwZIx52x3lwjksQnsnEHcJbAQ0BF1Ap2GcOMto8oXEX7t3R4wndmhM6ZaKX+ XN8W6GdonJvkgWeJRWMnU0HqPDn+N+82Tgv19g6HXUlH1OuGrd3jOuF6mmmwOlyP/qzF /VIYIhdIzW6+sM+K9IDSQOkgb+D+Z1tigiGMrcR3oBaSJYML2wdEr3rAFtY2OCdiulPi 32VgeN83HAIBE13LsK6bdV0EbiTOYoJ5n+SH6pnDR7+V+YsZitV1+jsah/7IfPvPQU8G Pyqw== X-Gm-Message-State: AElRT7G0qc5hApMpeEUgaBdihypHpMGX3AvPyGRthxzqdFuuj9x3KeKe yssqyV23I9Hr4LErTmhvGpOGM5zo X-Google-Smtp-Source: AG47ELubbIwBnGm91uqT/NZX/YfXqNV/tMbTbBtEh/QBDRKNQhkqB+BmrhpmoarzJ2HSYjbyTNI86A== X-Received: by 10.223.141.143 with SMTP id o15mr4923710wrb.272.1521298043049; Sat, 17 Mar 2018 07:47:23 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Sat, 17 Mar 2018 15:47:13 +0100 Message-Id: <20180317144714.18268-5-pbonzini@redhat.com> In-Reply-To: <20180317144714.18268-1-pbonzini@redhat.com> References: <20180317144714.18268-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sat, 17 Mar 2018 14:47:25 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sat, 17 Mar 2018 14:47:25 +0000 (UTC) for IP:'209.85.128.176' DOMAIN:'mail-wr0-f176.google.com' HELO:'mail-wr0-f176.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.497 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.128.176 mail-wr0-f176.google.com 209.85.128.176 mail-wr0-f176.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: patchew-devel@redhat.com Cc: Shubham Jain Subject: [Patchew-devel] [PATCH 4/5] rest: create separate results endpoint 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.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sat, 17 Mar 2018 14:47:34 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In the REST API, each series can have one or more results. Right now results are synthesized from message properties which are set by the applier-report and tester-report API. In order to simplify the conversion to REST of those APIs (e.g. using POST, PUT or PATCH requests), move the results out of the SeriesSerializer and into their own collection. For now, the ViewSet is not model-based, but I am including paginator-like fields so that it should be possible to change it to a ModelViewSet in the future. Signed-off-by: Paolo Bonzini --- api/rest.py | 75 +++++++++++++++++++++++++++++++++++++++++------= ---- api/urls.py | 5 ++++ mods/git.py | 4 +-- mods/testing.py | 4 +-- tests/test_git.py | 40 +++++++++++++++------------ tests/test_rest.py | 6 +++++ tests/test_testing.py | 28 +++++++++---------- 7 files changed, 111 insertions(+), 51 deletions(-) diff --git a/api/rest.py b/api/rest.py index 7df7618..3d22de8 100644 --- a/api/rest.py +++ b/api/rest.py @@ -8,19 +8,22 @@ # This work is licensed under the MIT License. Please see the LICENSE fil= e or # http://opensource.org/licenses/MIT. =20 -from collections import namedtuple +from collections import namedtuple, OrderedDict =20 from django.contrib.auth.models import User +from django.http import Http404 from django.template import loader =20 from mod import dispatch_module_hook from .models import Project, Message from .search import SearchEngine -from rest_framework import permissions, serializers, viewsets, filters, mi= xins, renderers +from rest_framework import (permissions, serializers, viewsets, filters, + mixins, generics, renderers) from rest_framework.decorators import detail_route -from rest_framework.fields import SerializerMethodField +from rest_framework.fields import SerializerMethodField, CharField, JSONFi= eld from rest_framework.relations import HyperlinkedIdentityField from rest_framework.response import Response +import rest_framework =20 SEARCH_PARAM =3D 'q' =20 @@ -143,16 +146,16 @@ class ProjectMessagesViewSetMixin(mixins.RetrieveMode= lMixin): def get_queryset(self): return self.queryset.filter(project=3Dself.kwargs['projects_pk']) =20 -class Result(namedtuple("Result", "name status log_url data")): +class Result(namedtuple("Result", "name status log_url message data")): __slots__ =3D () =20 - def __new__(cls, name, status, log_url=3DNone, data=3DNone, request=3D= None): + def __new__(cls, name, status, message, log_url=3DNone, data=3DNone, r= equest=3DNone): if log_url is not None and request is not None: log_url =3D request.build_absolute_uri(log_url) if status not in ('pending', 'success', 'failure'): raise ValueError("invalid value '%s' for status field" % statu= s) return super(cls, Result).__new__(cls, status=3Dstatus, log_url=3D= log_url, - data=3Ddata, name=3Dname) + message=3Dmessage, data=3Ddata, = name=3Dname) =20 # Series =20 @@ -176,8 +179,8 @@ class SeriesSerializer(BaseMessageSerializer): =20 resource_uri =3D HyperlinkedMessageField(view_name=3D'series-detail') message =3D HyperlinkedMessageField(view_name=3D'messages-detail') + results =3D HyperlinkedMessageField(view_name=3D'results-list', lookup= _field=3D'series_message_id') total_patches =3D SerializerMethodField() - results =3D SerializerMethodField() =20 def __init__(self, *args, **kwargs): self.detailed =3D kwargs.pop('detailed', False) @@ -190,13 +193,6 @@ class SeriesSerializer(BaseMessageSerializer): fields=3Dfields, detailed=3Dself.detailed) return fields =20 - def get_results(self, message): - results =3D [] - request =3D self.context['request'] - dispatch_module_hook("rest_results_hook", request=3Drequest, - message=3Dmessage, results=3Dresults) - return {x.name: x._asdict() for x in results} - def get_total_patches(self, obj): return obj.get_total_patches() =20 @@ -329,3 +325,54 @@ class MessagesViewSet(ProjectMessagesViewSetMixin, serializer =3D BaseMessageSerializer(page, many=3DTrue, context=3Dself.get_serializer_c= ontext()) return self.get_paginated_response(serializer.data) + +# Results + +class HyperlinkedResultField(HyperlinkedIdentityField): + def get_url(self, obj, view_name, request, format): + message =3D obj.message + kwargs =3D {'projects_pk': message.project_id, 'series_message_id'= : message.message_id, + 'name': obj.name} + return self.reverse(view_name, kwargs=3Dkwargs, request=3Drequest,= format=3Dformat) + +class ResultSerializer(serializers.Serializer): + resource_uri =3D HyperlinkedResultField(view_name=3D'results-detail') + name =3D CharField() + status =3D CharField() # one of 'failure', 'success', 'pending' + log_url =3D CharField(required=3DFalse) + data =3D JSONField(required=3DFalse) + +class SeriesResultsViewSet(viewsets.ViewSet, generics.GenericAPIView): + serializer_class =3D ResultSerializer + lookup_field =3D 'name' + lookup_value_regex =3D '[^/]+' + + def get_queryset(self): + return Message.objects.filter(project=3Dself.kwargs['projects_pk'], + message_id=3Dself.kwargs['series_mes= sage_id']) + + def get_results(self): + message =3D self.get_queryset()[0] + results =3D [] + dispatch_module_hook("rest_results_hook", request=3Dself.request, + message=3Dmessage, results=3Dresults) + return {x.name: x for x in results} + + def list(self, request, *args, **kwargs): + results =3D self.get_results().values() + serializer =3D self.get_serializer(results, many=3DTrue) + # Fake paginator response for forwards-compatibility, in case + # this ViewSet becomes model-based + return Response(OrderedDict([ + ('count', len(results)), + ('results', serializer.data) + ])) + + def retrieve(self, request, name, *args, **kwargs): + results =3D self.get_results() + try: + result =3D results[name] + except KeyError: + raise Http404 + serializer =3D self.get_serializer(result) + return Response(serializer.data) diff --git a/api/urls.py b/api/urls.py index 0a447f0..becabeb 100644 --- a/api/urls.py +++ b/api/urls.py @@ -37,11 +37,16 @@ projects_router.include_format_suffixes =3D False projects_router.register('series', rest.ProjectSeriesViewSet, base_name=3D= 'series') projects_router.register('messages', rest.MessagesViewSet, base_name=3D'me= ssages') =20 +results_router =3D NestedDefaultRouter(projects_router, 'series', lookup= =3D'series', trailing_slash=3DTrue) +results_router.include_format_suffixes =3D False +results_router.register('results', rest.SeriesResultsViewSet, base_name=3D= 'results') + schema_view =3D get_schema_view(title=3D'API schema') =20 urlpatterns =3D _build_urls() + [ url(r"v1/", include(router.urls)), url(r"v1/", include(projects_router.urls)), + url(r"v1/", include(results_router.urls)), url(r'^v1/schema/$', schema_view), # Use the base class's handler by default url(r".*", views.APIView.as_view()) diff --git a/mods/git.py b/mods/git.py index fc71174..8164854 100644 --- a/mods/git.py +++ b/mods/git.py @@ -129,8 +129,8 @@ class GitModule(PatchewModule): else: status =3D 'pending' log_url =3D None - results.append(Result(name=3D'git', status=3Dstatus, log_url=3Dlog= _url, data=3Ddata, - request=3Drequest)) + results.append(Result(name=3D'git', message=3Dmessage, status=3Dst= atus, + log_url=3Dlog_url, data=3Ddata, request=3Dre= quest)) =20 def prepare_message_hook(self, request, message, detailed): if not message.is_series_head: diff --git a/mods/testing.py b/mods/testing.py index 970256d..6f7d1ae 100644 --- a/mods/testing.py +++ b/mods/testing.py @@ -290,8 +290,8 @@ class TestingModule(PatchewModule): failed =3D not p["passed"] log_url =3D self.reverse_testing_log(message, tn, request=3Dre= quest, html=3DFalse) passed_str =3D "failure" if failed else "success" - results.append(Result(name=3D'testing.' + tn, status=3Dpassed_= str, log_url=3Dlog_url, - request=3Drequest)) + results.append(Result(name=3D'testing.' + tn, message=3Dmessag= e, status=3Dpassed_str, + log_url=3Dlog_url, request=3Drequest)) =20 def prepare_message_hook(self, request, message, detailed): if not message.is_series_head: diff --git a/tests/test_git.py b/tests/test_git.py index 4744ef4..fdf6b67 100755 --- a/tests/test_git.py +++ b/tests/test_git.py @@ -103,31 +103,37 @@ class GitTest(PatchewTestCase): self.repo + " patchew/20160628014747.20971-2-famz= @redhat.com") =20 def test_rest_need_apply(self): - resp =3D self.apply_and_retrieve("0013-foo-patch.mbox.gz", self.p.= id, - "20160628014747.20971-1-famz@redhat= .com") - self.assertEqual(resp.data['results']['git']['status'], 'pending') + self.cli_import("0013-foo-patch.mbox.gz") + MESSAGE_ID =3D '20160628014747.20971-1-famz@redhat.com' + resp =3D self.api_client.get('%sseries/%s/results/git/' % (self.PR= OJECT_BASE, MESSAGE_ID)) + self.assertEqual(resp.data['status'], 'pending') + self.assertEqual(resp.data['log_url'], None) =20 def test_rest_apply_failure(self): self.cli_import("0014-bar-patch.mbox.gz") self.do_apply() - resp =3D self.api_client.get(self.REST_BASE + 'series/?q=3Dproject= :QEMU') - self.assertEqual(resp.data['results'][0]['is_complete'], True) - self.assertEqual(resp.data['results'][0]['results']['git']['status= '], 'failure') - self.assertEqual('repo' in resp.data['results'][0]['results']['git= '], False) - self.assertEqual('tag' in resp.data['results'][0]['results']['git'= ], False) - log =3D self.client.get(resp.data['results'][0]['results']['git'][= 'log_url']) - self.assertEquals(log.status_code, 200) + MESSAGE_ID =3D '20160628014747.20971-2-famz@redhat.com' + resp =3D self.api_client.get('%sseries/%s/' % (self.PROJECT_BASE, = MESSAGE_ID)) + self.assertEqual(resp.data['is_complete'], True) + resp =3D self.api_client.get('%sseries/%s/results/git/' % (self.PR= OJECT_BASE, MESSAGE_ID)) + self.assertEqual(resp.data['status'], 'failure') + self.assertEqual('repo' in resp.data, False) + self.assertEqual('tag' in resp.data, False) + log =3D self.client.get(resp.data['log_url']) + self.assertEqual(log.status_code, 200) =20 def test_rest_apply_success(self): self.cli_import("0013-foo-patch.mbox.gz") self.do_apply() - resp =3D self.api_client.get(self.REST_BASE + 'series/?q=3Dproject= :QEMU') - self.assertEqual(resp.data['results'][0]['is_complete'], True) - self.assertEqual(resp.data['results'][0]['results']['git']['status= '], 'success') - self.assertEqual(resp.data['results'][0]['results']['git']['data']= ['repo'], self.repo) - self.assertEqual(resp.data['results'][0]['results']['git']['data']= ['tag'], "refs/tags/patchew/20160628014747.20971-1-famz@redhat.com") - log =3D self.client.get(resp.data['results'][0]['results']['git'][= 'log_url']) - self.assertEquals(log.status_code, 200) + MESSAGE_ID =3D '20160628014747.20971-1-famz@redhat.com' + resp =3D self.api_client.get('%sseries/%s/' % (self.PROJECT_BASE, = MESSAGE_ID)) + self.assertEqual(resp.data['is_complete'], True) + resp =3D self.api_client.get('%sseries/%s/results/git/' % (self.PR= OJECT_BASE, MESSAGE_ID)) + self.assertEqual(resp.data['status'], 'success') + self.assertEqual(resp.data['data']['repo'], self.repo) + self.assertEqual(resp.data['data']['tag'], "refs/tags/patchew/2016= 0628014747.20971-1-famz@redhat.com") + log =3D self.client.get(resp.data['log_url']) + self.assertEqual(log.status_code, 200) =20 if __name__ =3D=3D '__main__': main() diff --git a/tests/test_rest.py b/tests/test_rest.py index 1a7285b..38fd6bf 100755 --- a/tests/test_rest.py +++ b/tests/test_rest.py @@ -193,6 +193,12 @@ class RestTest(PatchewTestCase): resp =3D self.api_client.get(self.REST_BASE + 'projects/12345/seri= es/') self.assertEqual(resp.data['count'], 0) =20 + def test_series_results_list(self): + resp1 =3D self.apply_and_retrieve('0001-simple-patch.mbox.gz', + self.p.id, '20160628014747.20971-1-= famz@redhat.com') + resp =3D self.api_client.get(resp1.data['results']) + self.assertEqual(resp.data['count'], len(resp.data['results'])) + def test_series_search(self): resp1 =3D self.apply_and_retrieve('0004-multiple-patch-reviewed.mb= ox.gz', self.p.id, '1469192015-16487-1-git= -send-email-berrange@redhat.com') diff --git a/tests/test_testing.py b/tests/test_testing.py index 0d7e316..9bc03ab 100755 --- a/tests/test_testing.py +++ b/tests/test_testing.py @@ -94,41 +94,37 @@ class TestingTest(PatchewTestCase): capabilities=3D[]) self.assertFalse(td) =20 - def test_rest_basic(self): - resp =3D self.api_client.get(self.PROJECT_BASE + 'series/' + self.= msg.message_id + '/') - self.assertEquals('testing.tests' in resp.data['results'], False) - def test_rest_done_success(self): self.msg_testing_done(log=3D'everything good!', passed=3DTrue) - resp =3D self.api_client.get(self.PROJECT_BASE + 'series/' + self.= msg.message_id + '/') - self.assertEquals(resp.data['results']['testing.tests']['status'],= 'success') - log =3D self.client.get(resp.data['results']['testing.tests']['log= _url']) + resp =3D self.api_client.get('%sseries/%s/results/testing.tests/' = % (self.PROJECT_BASE, self.msg.message_id)) + self.assertEquals(resp.data['status'], 'success') + log =3D self.client.get(resp.data['log_url']) self.assertEquals(log.status_code, 200) self.assertEquals(log.content, b'everything good!') =20 def test_rest_done_failure(self): self.msg_testing_done(log=3D'sorry no good', passed=3DFalse) - resp =3D self.api_client.get(self.PROJECT_BASE + 'series/' + self.= msg.message_id + '/') - self.assertEquals(resp.data['results']['testing.tests']['status'],= 'failure') - log =3D self.client.get(resp.data['results']['testing.tests']['log= _url']) + resp =3D self.api_client.get('%sseries/%s/results/testing.tests/' = % (self.PROJECT_BASE, self.msg.message_id)) + self.assertEquals(resp.data['status'], 'failure') + log =3D self.client.get(resp.data['log_url']) self.assertEquals(log.status_code, 200) self.assertEquals(log.content, b'sorry no good') =20 def test_api_report_success(self): self.api_login() msgid =3D self.msg_testing_report(log=3D'everything good!', passed= =3DTrue) - resp =3D self.api_client.get(self.PROJECT_BASE + 'series/' + self.= msg.message_id + '/') - self.assertEquals(resp.data['results']['testing.a']['status'], 'su= ccess') - log =3D self.client.get(resp.data['results']['testing.a']['log_url= ']) + resp =3D self.api_client.get('%sseries/%s/results/testing.a/' % (s= elf.PROJECT_BASE, self.msg.message_id)) + self.assertEquals(resp.data['status'], 'success') + log =3D self.client.get(resp.data['log_url']) self.assertEquals(log.status_code, 200) self.assertEquals(log.content, b'everything good!') =20 def test_api_report_failure(self): self.api_login() msgid =3D self.msg_testing_report(log=3D'sorry no good', passed=3D= False) - resp =3D self.api_client.get(self.PROJECT_BASE + 'series/' + self.= msg.message_id + '/') - self.assertEquals(resp.data['results']['testing.a']['status'], 'fa= ilure') - log =3D self.client.get(resp.data['results']['testing.a']['log_url= ']) + resp =3D self.api_client.get('%sseries/%s/results/testing.a/' % (s= elf.PROJECT_BASE, self.msg.message_id)) + self.assertEquals(resp.data['status'], 'failure') + log =3D self.client.get(resp.data['log_url']) self.assertEquals(log.status_code, 200) self.assertEquals(log.content, b'sorry no good') =20 --=20 2.16.2 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Fri Apr 26 01:38:17 2024 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 1521298050515631.0940379658294; Sat, 17 Mar 2018 07:47:30 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9A7C1356C1; Sat, 17 Mar 2018 14:47:29 +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 8E9FF80E99; Sat, 17 Mar 2018 14:47:29 +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 84FB21808800; Sat, 17 Mar 2018 14:47:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2HElSfE007079 for ; Sat, 17 Mar 2018 10:47:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0C77C80E82; Sat, 17 Mar 2018 14:47:28 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 060B35FCCB for ; Sat, 17 Mar 2018 14:47:28 +0000 (UTC) Received: from mail-wr0-f180.google.com (mail-wr0-f180.google.com [209.85.128.180]) (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 60D904DD7C for ; Sat, 17 Mar 2018 14:47:26 +0000 (UTC) Received: by mail-wr0-f180.google.com with SMTP id f14so14309207wre.8 for ; Sat, 17 Mar 2018 07:47:26 -0700 (PDT) Received: from donizetti.lan (94-36-191-219.adsl-ull.clienti.tiscali.it. [94.36.191.219]) by smtp.gmail.com with ESMTPSA id p12sm7724855wre.89.2018.03.17.07.47.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 17 Mar 2018 07:47:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=9Bsthdx+Ui8ILZFO8JMJxKqGrgRXl64ieWo1jwi5WlI=; b=UzjxNn157IFLEOpb7FmpiJ9NyK/POodK164rL9oQAvKT+8i6m6aAPou8Kqg6L1PaxM sniuFo6WGeKfStXPEjfl6Clf2osVC26XBiFYnuCv/JJKmZADWmI9UMyAmTughswIEoHn li2B9w27phkNcYFMt45i29YGeG7PZ25iOjcXpY+Pofc8RTKIpL3YrpfxBN6wGUbAdKmJ A44rqhxM7huld1VBKHTWyT6+4aA28qSYe2x15+3/f3tlBwQ2/6c7AIYzMNq9bJkJGODK fiuTh6Knyf35PzDwHH4HcQJcc9ouCaRYDAiqWLicLTUWKqljDAyM79sbh5EaYwBF222o ga2g== 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:cc:subject:date:message-id :in-reply-to:references; bh=9Bsthdx+Ui8ILZFO8JMJxKqGrgRXl64ieWo1jwi5WlI=; b=P9ZXxCOH6EZPlQdtDZsn1Rhf0qVuOB1jadn0XHpfyLK1qAwTVZWopFY/Xnj55ZaDtu h85je/IbCt2KwrMZqAWUDMJS7OOBkcF5re4vL3QD6Mrg2G+AZsUQKefHyJ9bX7gr1Lrw mpByjxWYgV4JnXmKmaJEmnTfgxXk4zlrY7dqHqSap5h+1+c8G/NmtgNJwKTF0K0ZqAfc LzZWBUo8dRCI9QwvpV/KfFURs5xhM1rR3HxnXrZvQqu6vbxweZ0LUjwstdolceYpaKH/ 0S6z5tkGhsaBg2GT9ILWgWaIe3JAgQaX8uY8Z1aPaSc6uIviNm+mgqWg/OESgsOkzl0t nH4Q== X-Gm-Message-State: AElRT7GeSOqSgb7842sZzqwjb/IWyKRZsPbMhEp+gcksPoBsjFbrJf7y muM/Q8uO8MALSgaA/1GXA/8AGZGu X-Google-Smtp-Source: AG47ELsa/HsvUxxf9msLEYdlfb1tZ5e5cMI1Ms4OBvyB38pYjlJM5qbluhDvwWjC8S/63pIIQXrLCw== X-Received: by 10.223.199.10 with SMTP id k10mr4521005wrg.186.1521298044533; Sat, 17 Mar 2018 07:47:24 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Sat, 17 Mar 2018 15:47:14 +0100 Message-Id: <20180317144714.18268-6-pbonzini@redhat.com> In-Reply-To: <20180317144714.18268-1-pbonzini@redhat.com> References: <20180317144714.18268-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sat, 17 Mar 2018 14:47:26 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sat, 17 Mar 2018 14:47:26 +0000 (UTC) for IP:'209.85.128.180' DOMAIN:'mail-wr0-f180.google.com' HELO:'mail-wr0-f180.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.487 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.128.180 mail-wr0-f180.google.com 209.85.128.180 mail-wr0-f180.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: patchew-devel@redhat.com Cc: Shubham Jain Subject: [Patchew-devel] [PATCH 5/5] rest: include log directly in /.../results/xyz 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.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sat, 17 Mar 2018 14:47:29 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Returning all the logs in the list view might make the response too large, but we include it when retrieving a single result. This also makes sense because a POST or PUT request for a result should include the log. Signed-off-by: Paolo Bonzini --- api/rest.py | 24 ++++++++++++++++-------- mods/git.py | 9 +++++---- mods/testing.py | 8 ++++++-- tests/test_git.py | 9 +++++++++ tests/test_testing.py | 4 ++++ 5 files changed, 40 insertions(+), 14 deletions(-) diff --git a/api/rest.py b/api/rest.py index 3d22de8..1205981 100644 --- a/api/rest.py +++ b/api/rest.py @@ -146,15 +146,15 @@ class ProjectMessagesViewSetMixin(mixins.RetrieveMode= lMixin): def get_queryset(self): return self.queryset.filter(project=3Dself.kwargs['projects_pk']) =20 -class Result(namedtuple("Result", "name status log_url message data")): +class Result(namedtuple("Result", "name status log log_url message data")): __slots__ =3D () =20 - def __new__(cls, name, status, message, log_url=3DNone, data=3DNone, r= equest=3DNone): + def __new__(cls, name, status, message, log=3DNone, log_url=3DNone, da= ta=3DNone, request=3DNone): if log_url is not None and request is not None: log_url =3D request.build_absolute_uri(log_url) if status not in ('pending', 'success', 'failure'): raise ValueError("invalid value '%s' for status field" % statu= s) - return super(cls, Result).__new__(cls, status=3Dstatus, log_url=3D= log_url, + return super(cls, Result).__new__(cls, status=3Dstatus, log=3Dlog,= log_url=3Dlog_url, message=3Dmessage, data=3Ddata, = name=3Dname) =20 # Series @@ -342,8 +342,10 @@ class ResultSerializer(serializers.Serializer): log_url =3D CharField(required=3DFalse) data =3D JSONField(required=3DFalse) =20 +class ResultSerializerFull(ResultSerializer): + log =3D CharField(required=3DFalse) + class SeriesResultsViewSet(viewsets.ViewSet, generics.GenericAPIView): - serializer_class =3D ResultSerializer lookup_field =3D 'name' lookup_value_regex =3D '[^/]+' =20 @@ -351,15 +353,21 @@ class SeriesResultsViewSet(viewsets.ViewSet, generics= .GenericAPIView): return Message.objects.filter(project=3Dself.kwargs['projects_pk'], message_id=3Dself.kwargs['series_mes= sage_id']) =20 - def get_results(self): + def get_serializer_class(self, *args, **kwargs): + if self.lookup_field in self.kwargs: + return ResultSerializerFull + return ResultSerializer + + def get_results(self, detailed): message =3D self.get_queryset()[0] results =3D [] dispatch_module_hook("rest_results_hook", request=3Dself.request, - message=3Dmessage, results=3Dresults) + message=3Dmessage, results=3Dresults, + detailed=3Ddetailed) return {x.name: x for x in results} =20 def list(self, request, *args, **kwargs): - results =3D self.get_results().values() + results =3D self.get_results(detailed=3DFalse).values() serializer =3D self.get_serializer(results, many=3DTrue) # Fake paginator response for forwards-compatibility, in case # this ViewSet becomes model-based @@ -369,7 +377,7 @@ class SeriesResultsViewSet(viewsets.ViewSet, generics.G= enericAPIView): ])) =20 def retrieve(self, request, name, *args, **kwargs): - results =3D self.get_results() + results =3D self.get_results(detailed=3DTrue) try: result =3D results[name] except KeyError: diff --git a/mods/git.py b/mods/git.py index 8164854..44c883a 100644 --- a/mods/git.py +++ b/mods/git.py @@ -114,10 +114,10 @@ class GitModule(PatchewModule): raise Exception("Project git repo invalid: %s" % project_git) return upstream, branch =20 - def rest_results_hook(self, request, message, results): - l =3D message.get_property("git.apply-log") + def rest_results_hook(self, request, message, results, detailed=3DFals= e): + log =3D message.get_property("git.apply-log") data =3D None - if l: + if log: if message.get_property("git.apply-failed"): status =3D 'failure' else: @@ -130,7 +130,8 @@ class GitModule(PatchewModule): status =3D 'pending' log_url =3D None results.append(Result(name=3D'git', message=3Dmessage, status=3Dst= atus, - log_url=3Dlog_url, data=3Ddata, request=3Dre= quest)) + log=3Dlog, log_url=3Dlog_url, data=3Ddata, + request=3Drequest)) =20 def prepare_message_hook(self, request, message, detailed): if not message.is_series_head: diff --git a/mods/testing.py b/mods/testing.py index 6f7d1ae..3d02de1 100644 --- a/mods/testing.py +++ b/mods/testing.py @@ -282,7 +282,7 @@ class TestingModule(PatchewModule): return reverse("testing-get-prop", kwargs=3D{"project_or_series": obj.message_id}) =20 - def rest_results_hook(self, request, message, results): + def rest_results_hook(self, request, message, results, detailed=3DFals= e): for pn, p in message.get_properties().items(): if not pn.startswith("testing.report."): continue @@ -290,8 +290,12 @@ class TestingModule(PatchewModule): failed =3D not p["passed"] log_url =3D self.reverse_testing_log(message, tn, request=3Dre= quest, html=3DFalse) passed_str =3D "failure" if failed else "success" + if detailed: + log =3D message.get_property("testing.log." + tn) + else: + log =3D None results.append(Result(name=3D'testing.' + tn, message=3Dmessag= e, status=3Dpassed_str, - log_url=3Dlog_url, request=3Drequest)) + log=3Dlog, log_url=3Dlog_url, request=3D= request)) =20 def prepare_message_hook(self, request, message, detailed): if not message.is_series_head: diff --git a/tests/test_git.py b/tests/test_git.py index fdf6b67..c781ead 100755 --- a/tests/test_git.py +++ b/tests/test_git.py @@ -108,6 +108,7 @@ class GitTest(PatchewTestCase): resp =3D self.api_client.get('%sseries/%s/results/git/' % (self.PR= OJECT_BASE, MESSAGE_ID)) self.assertEqual(resp.data['status'], 'pending') self.assertEqual(resp.data['log_url'], None) + self.assertEqual(resp.data['log'], None) =20 def test_rest_apply_failure(self): self.cli_import("0014-bar-patch.mbox.gz") @@ -115,12 +116,19 @@ class GitTest(PatchewTestCase): MESSAGE_ID =3D '20160628014747.20971-2-famz@redhat.com' resp =3D self.api_client.get('%sseries/%s/' % (self.PROJECT_BASE, = MESSAGE_ID)) self.assertEqual(resp.data['is_complete'], True) + + resp =3D self.api_client.get('%sseries/%s/results/' % (self.PROJEC= T_BASE, MESSAGE_ID)) + self.assertEqual(resp.data['results'][0]['name'], 'git') + self.assertEqual('log' in resp.data['results'][0], False) + self.assertEqual('log_url' in resp.data['results'][0], True) + resp =3D self.api_client.get('%sseries/%s/results/git/' % (self.PR= OJECT_BASE, MESSAGE_ID)) self.assertEqual(resp.data['status'], 'failure') self.assertEqual('repo' in resp.data, False) self.assertEqual('tag' in resp.data, False) log =3D self.client.get(resp.data['log_url']) self.assertEqual(log.status_code, 200) + self.assertEqual(log.content.decode(), resp.data['log']) =20 def test_rest_apply_success(self): self.cli_import("0013-foo-patch.mbox.gz") @@ -134,6 +142,7 @@ class GitTest(PatchewTestCase): self.assertEqual(resp.data['data']['tag'], "refs/tags/patchew/2016= 0628014747.20971-1-famz@redhat.com") log =3D self.client.get(resp.data['log_url']) self.assertEqual(log.status_code, 200) + self.assertEqual(log.content.decode(), resp.data['log']) =20 if __name__ =3D=3D '__main__': main() diff --git a/tests/test_testing.py b/tests/test_testing.py index 9bc03ab..a23f93f 100755 --- a/tests/test_testing.py +++ b/tests/test_testing.py @@ -98,6 +98,7 @@ class TestingTest(PatchewTestCase): self.msg_testing_done(log=3D'everything good!', passed=3DTrue) resp =3D self.api_client.get('%sseries/%s/results/testing.tests/' = % (self.PROJECT_BASE, self.msg.message_id)) self.assertEquals(resp.data['status'], 'success') + self.assertEquals(resp.data['log'], 'everything good!') log =3D self.client.get(resp.data['log_url']) self.assertEquals(log.status_code, 200) self.assertEquals(log.content, b'everything good!') @@ -106,6 +107,7 @@ class TestingTest(PatchewTestCase): self.msg_testing_done(log=3D'sorry no good', passed=3DFalse) resp =3D self.api_client.get('%sseries/%s/results/testing.tests/' = % (self.PROJECT_BASE, self.msg.message_id)) self.assertEquals(resp.data['status'], 'failure') + self.assertEquals(resp.data['log'], 'sorry no good') log =3D self.client.get(resp.data['log_url']) self.assertEquals(log.status_code, 200) self.assertEquals(log.content, b'sorry no good') @@ -116,6 +118,7 @@ class TestingTest(PatchewTestCase): resp =3D self.api_client.get('%sseries/%s/results/testing.a/' % (s= elf.PROJECT_BASE, self.msg.message_id)) self.assertEquals(resp.data['status'], 'success') log =3D self.client.get(resp.data['log_url']) + self.assertEquals(resp.data['log'], 'everything good!') self.assertEquals(log.status_code, 200) self.assertEquals(log.content, b'everything good!') =20 @@ -124,6 +127,7 @@ class TestingTest(PatchewTestCase): msgid =3D self.msg_testing_report(log=3D'sorry no good', passed=3D= False) resp =3D self.api_client.get('%sseries/%s/results/testing.a/' % (s= elf.PROJECT_BASE, self.msg.message_id)) self.assertEquals(resp.data['status'], 'failure') + self.assertEquals(resp.data['log'], 'sorry no good') log =3D self.client.get(resp.data['log_url']) self.assertEquals(log.status_code, 200) self.assertEquals(log.content, b'sorry no good') --=20 2.16.2 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel