From nobody Fri Oct 18 08:29:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=patchew-devel-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1645604812; cv=none; d=zohomail.com; s=zohoarc; b=hXY2xkN7oR2jA35OGoCSTHj+8cqvGC5nKlURGLrPfcgaOkxzpCKO2zCJNOihINlUJJ1fbn1CgmFEjYZ4Q1WHXewny1ZGyGdQ5Mr0BaPlEc3M2L3mCqChxkzr6ZL3QWSRwYT2eo1bdMI4/pb2N7/6bzxbDxuWnZ+Hx/TlKNEu0Ps= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645604812; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZomkD645gvR/+mFEqFK1ChrYwPR8ZDyxfnWsGnRhW+Y=; b=i43+rqNT5FDW3jPHkgZWXa3/UF0oRjzFilWjbO1DaPMz0mV+l63ZnV6dF7j1PfS1jlELgBqovrq28OhErEAr6kHgj0zxyno+kaM65bYhAHyPD2EyAz20WkfebrAUdUC36YzoMjEDUp70b5vaIB+YynPLZwMXacbMEP9Ay5fHNkc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1645604812145893.0012769543449; Wed, 23 Feb 2022 00:26:52 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-368-uufQtUWtP66ZEyaEnEmQRA-1; Wed, 23 Feb 2022 03:26:42 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8C8ED51E0; Wed, 23 Feb 2022 08:26:41 +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 8426C8317D; Wed, 23 Feb 2022 08:26:41 +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 7CB801809CB3; Wed, 23 Feb 2022 08:26:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21N8Qelp028020 for ; Wed, 23 Feb 2022 03:26:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8EBE140E80ED; Wed, 23 Feb 2022 08:26:40 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8AA9040E80EC for ; Wed, 23 Feb 2022 08:26:40 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 742D33800505 for ; Wed, 23 Feb 2022 08:26:40 +0000 (UTC) Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-404-FLLzM7LKMIy33jDlWGSODg-1; Wed, 23 Feb 2022 03:26:38 -0500 Received: by mail-ej1-f50.google.com with SMTP id hw13so50472378ejc.9 for ; Wed, 23 Feb 2022 00:26:38 -0800 (PST) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id s18sm334929eja.87.2022.02.23.00.26.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 00:26:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645604810; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ZomkD645gvR/+mFEqFK1ChrYwPR8ZDyxfnWsGnRhW+Y=; b=JPW/W7AKZWXyLUPoBt4DRBbq+EeMqoiy5FQmq/C7DHoZad08TO1mWpy7JbMD+ASzaCpkqL frxCSNwm6nh1f1OI9b4XPth5TangQPqHo/z0ZIK6N8F0qMetKN17T2OwHy85XPKkZY8auZ u4aeB+wsnebXML0XqBpvCddk7vUGOtw= X-MC-Unique: uufQtUWtP66ZEyaEnEmQRA-1 X-MC-Unique: FLLzM7LKMIy33jDlWGSODg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=VtVg15NAxUZePVDScth5+SAPMM+yt/s4k4m8ZdwtBi0=; b=pEgz4JpP5RktHACrwEwP3ffEg+fvSS1FERqb0VHZ3xm08wup8FdaIUPV0dcfbNj/Ci USKR/twdfSJXfV0hNjW7ov8gyNz5AJZHkDeHwyVgDHZ5HAWeyOrO4pdq/45w3JCllr+G NVy9mFMLLzEPSmT4vQXNjBQ1E87B2I3hz+KG6BfW3V23uc2NfJYhCwjKA2dr0xCIjB5D svhZSdWvogJW3g+3+slqAMspJ4Mu7lbtlS+P1ovPw+CQiQFqBNnkn0IQx5JAjwIi7JCg Kp1pSson8ojjEjWeyTB79g9vFimBZyUR0Ned6c4c9iTnDq1HBM7n/rED/UKLZ+7URT74 genA== X-Gm-Message-State: AOAM533DFVfLMiWY7eeT/D2KwWfQu0JUBj19oFvVx/E+E0ckbCJ4pWQ7 cW91G0TPMLH/7rwc4Sfz6wwtJE41tZY= X-Google-Smtp-Source: ABdhPJxTOgfmlHKUl34zVhlyGrlqeOmj6EBl85fJIcXotjDXbXH+aAQNmRFk8tlIBDvXC4qlYq161g== X-Received: by 2002:a17:906:5a94:b0:6c5:5aa4:da87 with SMTP id l20-20020a1709065a9400b006c55aa4da87mr22953074ejq.381.1645604797656; Wed, 23 Feb 2022 00:26:37 -0800 (PST) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Wed, 23 Feb 2022 09:26:30 +0100 Message-Id: <20220223082631.228937-6-pbonzini@redhat.com> In-Reply-To: <20220223082631.228937-1-pbonzini@redhat.com> References: <20220223082631.228937-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 5/6] maintainer: add unit tests 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: , Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=patchew-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1645604813045100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- tests/test_maintainers.py | 93 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100755 tests/test_maintainers.py diff --git a/tests/test_maintainers.py b/tests/test_maintainers.py new file mode 100755 index 0000000..91ad044 --- /dev/null +++ b/tests/test_maintainers.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python3 +# +# Copyright 2022 Red Hat, Inc. +# +# Authors: +# Paolo Bonzini +# +# This work is licensed under the MIT License. Please see the LICENSE fil= e or +# http://opensource.org/licenses/MIT. + +from api.models import Message, WatchedQuery, QueuedSeries + +from .patchewtest import PatchewTestCase, main + + +class MaintainerQueueTest(PatchewTestCase): + def setUp(self): + self.testuser =3D self.create_user("test", "1234", groups=3D["impo= rter"]) + self.create_superuser() + self.cli_login() + self.add_project("QEMU", "qemu-devel@nongnu.org") + + def test_watched_query(self): + wq =3D WatchedQuery(user=3Dself.testuser, query=3D"to:qemu-block@n= ongnu.org") + wq.save() + self.cli_import("0001-simple-patch.mbox.gz") + msg =3D Message.objects.first() + query =3D QueuedSeries.objects.filter(user=3Dself.testuser, name= =3D"watched") + q =3D query.first() + assert q + assert q.message.id =3D=3D msg.id + + def test_update_watch_on_merge_change(self): + wq =3D WatchedQuery(user=3Dself.testuser, query=3D"to:qemu-block@n= ongnu.org -is:merged") + wq.save() + self.cli_import("0001-simple-patch.mbox.gz") + msg =3D Message.objects.first() + query =3D QueuedSeries.objects.filter(user=3Dself.testuser, name= =3D"watched") + q =3D query.first() + assert q + assert q.message.id =3D=3D msg.id + + msg.set_merged() + msg.save() + query =3D QueuedSeries.objects.filter(user=3Dself.testuser, name= =3D"watched") + q =3D query.first() + assert not q + + def test_update_watch_on_queue_add(self): + wq =3D WatchedQuery(user=3Dself.testuser, query=3D"to:qemu-block@n= ongnu.org -nack:test") + wq.save() + self.cli_import("0001-simple-patch.mbox.gz") + msg =3D Message.objects.first() + query =3D QueuedSeries.objects.filter(user=3Dself.testuser, name= =3D"watched") + q =3D query.first() + assert q + assert q.message.id =3D=3D msg.id + + # TODO: support and use REST API + self.client.post("/login/", {"username": "test", "password": "1234= "}) + self.client.get("/mark-as-rejected/" + msg.message_id + "/") + query =3D QueuedSeries.objects.filter(user=3Dself.testuser, name= =3D"reject") + q =3D query.first() + assert q + assert q.message.id =3D=3D msg.id + + query =3D QueuedSeries.objects.filter(user=3Dself.testuser, name= =3D"watched") + q =3D query.first() + assert not q + + def test_update_watch_on_queue_remove(self): + self.cli_import("0001-simple-patch.mbox.gz") + msg =3D Message.objects.first() + + # TODO: support and use REST API; same below + self.client.post("/login/", {"username": "test", "password": "1234= "}) + self.client.get("/mark-as-rejected/" + msg.message_id + "/") + query =3D QueuedSeries.objects.filter(user=3Dself.testuser, name= =3D"reject") + q =3D query.first() + assert q + assert q.message.id =3D=3D msg.id + + wq =3D WatchedQuery(user=3Dself.testuser, query=3D"to:qemu-block@n= ongnu.org -nack:test") + wq.save() + self.client.get("/clear-reviewed/" + msg.message_id + "/") + query =3D QueuedSeries.objects.filter(user=3Dself.testuser, name= =3D"watched") + q =3D query.first() + assert q + assert q.message.id =3D=3D msg.id + + +if __name__ =3D=3D "__main__": + main() --=20 2.34.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://listman.redhat.com/mailman/listinfo/patchew-devel