From nobody Tue May 13 12:49:31 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=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 1530870184903714.5889561351925; Fri, 6 Jul 2018 02:43:04 -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 5E9848764F; Fri, 6 Jul 2018 09:43:04 +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 4F43717008; Fri, 6 Jul 2018 09:43:04 +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 4330718037EC; Fri, 6 Jul 2018 09:43:04 +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 w669h34O012022 for ; Fri, 6 Jul 2018 05:43:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6869F3001933; Fri, 6 Jul 2018 09:43:03 +0000 (UTC) Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 60F03308332C for ; Fri, 6 Jul 2018 09:43:01 +0000 (UTC) Received: from mail-pf0-f179.google.com (mail-pf0-f179.google.com [209.85.192.179]) (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 60327308A943 for ; Fri, 6 Jul 2018 09:42:50 +0000 (UTC) Received: by mail-pf0-f179.google.com with SMTP id u16-v6so7983895pfh.3 for ; Fri, 06 Jul 2018 02:42:50 -0700 (PDT) Received: from localhost.localdomain ([182.74.40.122]) by smtp.gmail.com with ESMTPSA id r87-v6sm15257688pfb.1.2018.07.06.02.42.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 06 Jul 2018 02:42:48 -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=ZwSbGPVvtkgF9IsZvRpH78mntKxfsMe0LGPTy9lkFiU=; b=OxMPl1jM2DFcFb2pmWsO+Ut9orGq8/uXNpnsZV2VWkkevyMIvWMD5ys9osKURB4JSp QilMB3AkzYkIGNznoff+94x//d/Y0U0fiX51VcShQalK89kdQDsOV020U9mOkqnUI2GN 64wDvBpwDmUHeBFRn1znyoNR5RIgAZAAqm39J48A212z/Rjj0FhUJJPj9SdzI9w1DfCU X2dzupcMZIPv8EzINj719YQOvGcpCWhsQJ4nI5GnWjTG1cKjmlDg8p9jJxsnXuttZuqv z6tWLAQiUfmcgNp1YQu6bLnMHkKHUncUaQTfENKy5xjoymtcSjCYptDLGLbWb1H0eDew NaDQ== 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=ZwSbGPVvtkgF9IsZvRpH78mntKxfsMe0LGPTy9lkFiU=; b=egld2OBGPEayTYttbwZ2FXrdD7oREKD/05ZBEMUzWWVqPuIXoOFvi8GXmNPUB2K7M3 dzZxEWfW28MHnCltxFkyFYN68xvRkV0ktltHcMP66dnGC0d8bYKgZzwfsuBO6XGaeBIZ ECLZmAtXrrpzm+gN838ps2sLEnIrU5zWAhTTSFdx16bkP2bEES1zM/eyosm+JvwDHaXK 0YnsiM9LmUq/ylI/0uovKul4f8VrBCCihzOBBwLhD1LvJpHnCK+CSbsS8UkI3oiMHbXP qaZR/ZlIph7lSGwad5kVVYO+j8cNkcdFhh4Rck1MLwiIgJ/Z4zkxiNqvLkutu4kcAQ4J Mq9Q== X-Gm-Message-State: APt69E0brXcuIHN1NtdB/FtyGa5M0cOi1/WJfILBlrCygYPCjma+y/Iw VMqV94ihoJtaGY2d6zBTqnBsXg== X-Google-Smtp-Source: AAOMgpdepXya5qYZEm4pRS9nLyotThe2KMTHA9Un74ZS1b0KnmNAXU82pgqRcj0FeTpk+H857G4Elg== X-Received: by 2002:a65:6252:: with SMTP id q18-v6mr8952934pgv.106.1530870169431; Fri, 06 Jul 2018 02:42:49 -0700 (PDT) From: Shubham Jain To: patchew-devel@redhat.com Date: Fri, 6 Jul 2018 15:09:46 +0530 Message-Id: <20180706093947.20025-4-shubhamjain7495@gmail.com> In-Reply-To: <20180706093947.20025-1-shubhamjain7495@gmail.com> References: <20180706093947.20025-1-shubhamjain7495@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Fri, 06 Jul 2018 09:42:50 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Fri, 06 Jul 2018 09:42:50 +0000 (UTC) for IP:'209.85.192.179' DOMAIN:'mail-pf0-f179.google.com' HELO:'mail-pf0-f179.google.com' FROM:'shubhamjain7495@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.551 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, SPF_PASS, T_DKIM_INVALID) 209.85.192.179 mail-pf0-f179.google.com 209.85.192.179 mail-pf0-f179.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.41 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-loop: patchew-devel@redhat.com Cc: Shubham Jain Subject: [Patchew-devel] [PATCH v3 3/4] 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.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.26]); Fri, 06 Jul 2018 09:43:04 +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 | 15 ++++++++++++++- tests/patchewtest.py | 3 +++ tests/test_message.py | 17 +++++++++++++++-- 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/api/rest.py b/api/rest.py index 39bdda0..9b47f37 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, ) + def collect_patches(self, series): if series.is_patch: patches =3D [series] diff --git a/patchew-cli b/patchew-cli index 8425db2..f90f3c5 100755 --- a/patchew-cli +++ b/patchew-cli @@ -181,7 +181,20 @@ 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 args.all:=20 + 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: + series_resp =3D self.rest_api_do("series/?q%s"%term) + series_list =3D series_list + series_resp['results'] + for series in series_list: =20 + 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..0b47b37 100755 --- a/tests/test_message.py +++ b/tests/test_message.py @@ -10,7 +10,8 @@ =20 import time import datetime -from tests.patchewtest import PatchewTestCase, main +import json +from patchewtest import PatchewTestCase, main =20 class ProjectTest(PatchewTestCase): =20 @@ -54,5 +55,17 @@ class ProjectTest(PatchewTestCase): asctime =3D message.get_asctime() self.assertEqual(asctime, "Sat Oct 22 9:06:04 2016") =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") + a, b =3D self.check_cli(["search", "-r", "-o", "subject,properties= "]) + 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", "subject,properties= "]) + self.assertEqual("",a) + if __name__ =3D=3D '__main__': - main() + main() \ No newline at end of file --=20 2.15.1 (Apple Git-101) _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel