From nobody Thu Sep 19 01:02:18 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=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1531369334388690.1746052875071; Wed, 11 Jul 2018 21:22:14 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AACF33082A2B; Thu, 12 Jul 2018 04:22:13 +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 9DE515D9CA; Thu, 12 Jul 2018 04:22:13 +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 91DAA18037EC; Thu, 12 Jul 2018 04:22:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6C4MC4d020338 for ; Thu, 12 Jul 2018 00:22:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 699D8308BDB0; Thu, 12 Jul 2018 04:22:12 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6085F308BDAE for ; Thu, 12 Jul 2018 04:22:09 +0000 (UTC) Received: from mail-pl0-f47.google.com (mail-pl0-f47.google.com [209.85.160.47]) (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 6CE9C37EE0 for ; Thu, 12 Jul 2018 04:21:58 +0000 (UTC) Received: by mail-pl0-f47.google.com with SMTP id 30-v6so10097043pld.13 for ; Wed, 11 Jul 2018 21:21:58 -0700 (PDT) Received: from localhost.localdomain ([112.196.135.182]) by smtp.gmail.com with ESMTPSA id i12-v6sm31294658pgd.87.2018.07.11.21.21.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jul 2018 21:21:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2AFKMuJVHP67SFWiS/hXy8sMNjcYReU7LXL82qEjEw8=; b=m6OZZ9rpLhJ5s0EeLITay/vXFy091h0XBklcyimbCbDlVn7HwePrmCSs3f+hsXpls6 9fQ7RJMKXaWCaIBnBw6bk8o60neneD/gpVac4dpY3/d2emOKMBaQtn/Fi6W7RXnJVQp4 IFCbDKqD4V6bgTE/OViL/TR38DDlSSeNiot89PwOLqFZft3IuyFVTbt5jG7txSCQTCzk P7WOi0x5IDAbT0afURrQKabis0CfshvVFfmzj8eeuEBWxoIV/20aG18bPRcUdlv2ucxd i65GiuGStBwmpDwtYhftsZLfENmLQe4NJojaAjb95KHpRTCVZYBqH6RW2ph9UDRIdfB1 JgSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2AFKMuJVHP67SFWiS/hXy8sMNjcYReU7LXL82qEjEw8=; b=liWjXcsQbaa3gkSCzA8QhFUjh8NaiWygww//x4ZkSBnSE/q6dqTYg2YfDk3cXzG3Ve mvtWuRrurUq2gqXRiikVonWWgRxpACAA+g3RmV+Kqd6Kz62Qu8l0KskidyBSwX2GO6Ov M7VWMnQqRNh7kYZMIEAp5QUdjpfHnIvfeMbw0+Oi5Ecrnro31cVaiq+1hNLfG/4s0k2A Kg+XP3Tjl3tu8Po3Gx8+PzzB/k5hBsUklLtLC41c6q9HIevtVjzDjsU+NLKCDluSZ7Tg VFGpKSarDqnG6v8GwruIUXE9T2n3cckb0ldiLtFQXSi0+pnFVzYb1Qr+Kk5PJEih6/8J yhbA== X-Gm-Message-State: AOUpUlG1uTdhcx/cYdDj8JeuTFaa3ET4ZdgOPMVzZhBs8E+REe7XlmNH OKgcGbY3F9HHP+2r75Su2jkzPg== X-Google-Smtp-Source: AAOMgpcU0yoX2HjQ/ZOM3rUYllBqXAZCFvQGldzljnFBkXrCnD7HhBRsYtFkolcMy8hIQFrlRIullQ== X-Received: by 2002:a17:902:be0d:: with SMTP id r13-v6mr610009pls.299.1531369317402; Wed, 11 Jul 2018 21:21:57 -0700 (PDT) From: Shubham Jain To: patchew-devel@redhat.com Date: Thu, 12 Jul 2018 09:51:19 +0530 Message-Id: <20180712042120.2831-6-shubhamjain7495@gmail.com> In-Reply-To: <20180712042120.2831-1-shubhamjain7495@gmail.com> References: <20180712042120.2831-1-shubhamjain7495@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 12 Jul 2018 04:21:58 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 12 Jul 2018 04:21:58 +0000 (UTC) for IP:'209.85.160.47' DOMAIN:'mail-pl0-f47.google.com' HELO:'mail-pl0-f47.google.com' FROM:'shubhamjain7495@gmail.com' RCPT:'' X-RedHat-Spam-Score: 3.05 *** (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_SORBS_WEB, SPF_PASS, T_DKIM_INVALID) 209.85.160.47 mail-pl0-f47.google.com 209.85.160.47 mail-pl0-f47.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: patchew-devel@redhat.com Cc: Shubham Jain Subject: [Patchew-devel] [PATCH v5 5/6] Make Delete Command use REST 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 12 Jul 2018 04:22:13 +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" Make patchew-cli's delete use REST api and added the missing test for delete --- api/rest.py | 2 ++ patchew-cli | 16 +++++++++++++++- tests/patchewtest.py | 3 +++ tests/test_message.py | 15 +++++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/api/rest.py b/api/rest.py index 3045516..d714d09 100644 --- a/api/rest.py +++ b/api/rest.py @@ -320,6 +320,8 @@ class SeriesViewSet(BaseMessageViewSet): =20 class ProjectSeriesViewSet(ProjectMessagesViewSetMixin, SeriesViewSet, mixins.DestroyModelMixin): + authentication_classes =3D (CsrfExemptSessionAuthentication, ) + =20 def collect_patches(self, series): if series.is_patch: patches =3D [series] diff --git a/patchew-cli b/patchew-cli index 8029751..cb0b650 100755 --- a/patchew-cli +++ b/patchew-cli @@ -181,7 +181,21 @@ class DeleteCommand(SubCommand): if not argv and not args.all: print("Must specify --all to delete all patches") return 1 - self.api_do("delete", terms=3Dargv) + series_list =3D [] + if len(argv)=3D=3D0: + resp =3D self.rest_api_do("projects") + for project in len(resp['result']): + url =3D project['series'] + series_resp =3D self.rest_api_do(url) + series_list =3D series_list + series_resp['results'] + else: + for term in argv: + url =3D str(self.base_url) + "/api/v1/series/?q=3D" + term + series_resp =3D self.rest_api_do(url) + series_list =3D series_list + series_resp['results'] + for series in series_list: + url =3D series['resource_uri'] + self.rest_api_do(url, request_method=3D'delete') return 0 =20 class ImportCommand(SubCommand): diff --git a/tests/patchewtest.py b/tests/patchewtest.py index 5bed3b9..847b3f9 100644 --- a/tests/patchewtest.py +++ b/tests/patchewtest.py @@ -100,6 +100,9 @@ class PatchewTestCase(django.test.LiveServerTestCase): def cli_import(self, mbox, rc=3D0): self.check_cli(["import", self.get_data_path(mbox)], rc) =20 + def cli_delete(self, terms, rc=3D0): + self.check_cli(["delete", terms], rc) + def get_data_path(self, fname): r =3D tempfile.NamedTemporaryFile(dir=3DRUN_DIR, prefix=3D"test-da= ta-", delete=3DFalse) d =3D os.path.join(BASE_DIR, "tests", "data", fname) diff --git a/tests/test_message.py b/tests/test_message.py index 9448aee..4b60c1d 100755 --- a/tests/test_message.py +++ b/tests/test_message.py @@ -10,6 +10,7 @@ =20 import time import datetime +import json from tests.patchewtest import PatchewTestCase, main =20 class ProjectTest(PatchewTestCase): @@ -40,6 +41,20 @@ class ProjectTest(PatchewTestCase): age =3D message.get_age() self.assertEqual(age, "1 day") =20 + def test_delete(self): + self.cli_login() + self.add_project("QEMU", "qemu-devel@nongnu.org") + self.cli_import("0002-unusual-cased-tags.mbox.gz") + self.cli_import("0004-multiple-patch-reviewed.mbox.gz") + a, b =3D self.check_cli(["search", "-r", "-o", "subject,properties= ,message-id"]) + ao =3D json.loads(a)[0] + self.assertEqual(["Fam Zheng", "famz@redhat.com"], + ao["properties"]["reviewers"][0]) + self.cli_delete("from:Fam") + a, b =3D self.check_cli(["search", "-r", "-o", "message-id"]) + ao =3D json.loads(a)[0] + self.assertEqual("1469192015-16487-1-git-send-email-berrange@redha= t.com", ao['message-id']) + def test_asctime(self): from api.models import Message message =3D Message() --=20 2.15.1 (Apple Git-101) _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel