From nobody Mon Sep 16 19:27:09 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 153090202608617.427316896323305; Fri, 6 Jul 2018 11:33:46 -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 8D3955BEB8; Fri, 6 Jul 2018 18:33:45 +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 7BCE653B2E; Fri, 6 Jul 2018 18:33:45 +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 6B0831800B68; Fri, 6 Jul 2018 18:33:45 +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 w66IXiCR014158 for ; Fri, 6 Jul 2018 14:33:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7A45B5B681; Fri, 6 Jul 2018 18:33:44 +0000 (UTC) Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7297C5B680 for ; Fri, 6 Jul 2018 18:33:39 +0000 (UTC) Received: from mail-pl0-f53.google.com (mail-pl0-f53.google.com [209.85.160.53]) (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 49AF93086245 for ; Fri, 6 Jul 2018 18:33:28 +0000 (UTC) Received: by mail-pl0-f53.google.com with SMTP id k1-v6so3242539plt.2 for ; Fri, 06 Jul 2018 11:33:28 -0700 (PDT) Received: from localhost.localdomain ([112.196.135.85]) by smtp.gmail.com with ESMTPSA id o4-v6sm19941545pfa.128.2018.07.06.11.33.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 06 Jul 2018 11:33:26 -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=b+yP/EltRfTX01DjCZGR12/V4Jr0Ij1fik+UuBcI15Y=; b=dm7L/aigIGJC3Y/YTBz/to+KwLqBr9cdszG81Q8DhtVthMvQzy9wgGjxmPXzLaHQBV uvvymtIgsusyHrux9z5/qx1G6S6V3Z4dzjuYdQSI1JU8hAaMYwYpabAWGOUXnuCQa5+0 PILK1QIqdLY6NRmqFa8u6dkOseUDgceSH6wiKcubxKNbbytBpuWgGe2zBLO9IiqsgXTR TuUTDEwwf79Q7w8k4fM0DVt2pg2nQx41KwP9brYI74n192x6chV0M+lsi1mQaFvD+jqB c3rEH27eVW6/2wb4QfmqsAt8yMci/wEfrX1b/Nkr9otX+wWowqzKvO5VZfajPDmC3RYb cSvg== 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=b+yP/EltRfTX01DjCZGR12/V4Jr0Ij1fik+UuBcI15Y=; b=RyHa1A5SVkAtqFeUyXILEiZ0ctrEG2SGfYJLo+Iqb1WiqyS/BpIGOrBu9eHU4x0bps Hs0P5doqxwyla5RrqVZvTuiBVoRAoirmPQVGuU+1knUGeyMow/U4FSn453R1aUPWo9ee 6sqqWCxcPi/ki8Ys1JfuKXV6b6PwJ52uKJTLML4qqEymkqrpLHR/ROjesoBkDWdHH2BK 4lfSiyAGdqUO8/MpfnZ7Mmty7HtJMLR00nijLPfpM6M30rjMxTJ1/Fzi9wdMY6byzJ+r dGog/A4ikFSffl1/0jDC4uu5jHyddY61HmK/PsIG9zb+Y9dgDJLxN8XsGGbONQqZTzwK er7Q== X-Gm-Message-State: APt69E37I2cZCJBT5ZqAY5zjhgj2EJEIO6ESKntKkPAnwBT1EPHjF9SG 6R+E3+XeB+jVg/ULAgb7A8wt6Q== X-Google-Smtp-Source: AAOMgpfHACKtvCZDhewa5ia6N4gQGyyojwUywffYYOGFIrY6HH4p9hc0PCsgqLBNWFvvS4h/fzL0aA== X-Received: by 2002:a17:902:e85:: with SMTP id 5-v6mr11315912plx.318.1530902007228; Fri, 06 Jul 2018 11:33:27 -0700 (PDT) From: Shubham Jain To: patchew-devel@redhat.com Date: Sat, 7 Jul 2018 00:02:06 +0530 Message-Id: <20180706183207.31842-4-shubhamjain7495@gmail.com> In-Reply-To: <20180706183207.31842-1-shubhamjain7495@gmail.com> References: <20180706183207.31842-1-shubhamjain7495@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 06 Jul 2018 18:33:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 06 Jul 2018 18:33:28 +0000 (UTC) for IP:'209.85.160.53' DOMAIN:'mail-pl0-f53.google.com' HELO:'mail-pl0-f53.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.160.53 mail-pl0-f53.google.com 209.85.160.53 mail-pl0-f53.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: patchew-devel@redhat.com Cc: Shubham Jain Subject: [Patchew-devel] [PATCH v4 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.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.38]); Fri, 06 Jul 2018 18:33:45 +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 | 13 +++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/api/rest.py b/api/rest.py index 39bdda0..c7818c4 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 9d9fde0..509bb62 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: + 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: + 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..ae308a5 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): @@ -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() --=20 2.15.1 (Apple Git-101) _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel