From nobody Tue May 13 20:07:34 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; 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 1532664018796629.5837092460656; Thu, 26 Jul 2018 21:00:18 -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 09C7F821C7; Fri, 27 Jul 2018 04:00:17 +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 EB729600C5; Fri, 27 Jul 2018 04:00:16 +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 D9C2F4BB78; Fri, 27 Jul 2018 04:00:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6R40FNV018749 for ; Fri, 27 Jul 2018 00:00:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7C73A111C4BE; Fri, 27 Jul 2018 04:00:15 +0000 (UTC) Received: from lemon.usersys.redhat.com (ovpn-12-150.pek2.redhat.com [10.72.12.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id 58DB3111C4AB; Fri, 27 Jul 2018 04:00:13 +0000 (UTC) From: Fam Zheng To: patchew-devel@redhat.com Date: Fri, 27 Jul 2018 11:59:34 +0800 Message-Id: <20180727035934.32555-12-famz@redhat.com> In-Reply-To: <20180727035934.32555-1-famz@redhat.com> References: <20180727035934.32555-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH v2 11/11] tests: Use requirements in test 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]); Fri, 27 Jul 2018 04:00:17 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Fam Zheng --- tests/test_testing.py | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/tests/test_testing.py b/tests/test_testing.py index c1a1c94..7a40ec3 100755 --- a/tests/test_testing.py +++ b/tests/test_testing.py @@ -16,12 +16,12 @@ sys.path.append(os.path.dirname(__file__)) from tests.patchewtest import PatchewTestCase, main from api.models import Message, Result =20 -def create_test(project, name): +def create_test(project, name, requirements=3D""): prefix =3D "testing.tests." + name + "." project.set_property(prefix + "timeout", 3600) project.set_property(prefix + "enabled", True) project.set_property(prefix + "script", "#!/bin/bash\ntrue") - project.set_property(prefix + "requirements", "") + project.set_property(prefix + "requirements", requirements) =20 class TestingTestCase(PatchewTestCase, metaclass=3Dabc.ABCMeta): =20 @@ -197,17 +197,31 @@ class TesterTest(PatchewTestCase): self.create_superuser() =20 self.repo =3D self.create_git_repo("repo") + self.p1 =3D self.add_project("QEMU", "qemu-devel@nongnu.org") create_test(self.p1, "a") + self.p2 =3D self.add_project("UMEQ", "qemu-devel@nongnu.org") create_test(self.p2, "b") =20 + self.p3 =3D self.add_project("ALLOW", "qemu-devel@nongnu.org") + self.p3.set_property("testing.requirements.allow.script", + "#!/bin/sh\ntrue") + create_test(self.p3, "c", "allow") + + self.p4 =3D self.add_project("DENY", "qemu-devel@nongnu.org") + self.p4.set_property("testing.requirements.deny.script", + "#!/bin/sh\nfalse") + create_test(self.p4, "d", "deny") + self.cli_login() self.cli_import('0013-foo-patch.mbox.gz') self.cli_logout() =20 self.update_head(self.p1) self.update_head(self.p2) + self.update_head(self.p3) + self.update_head(self.p4) base =3D subprocess.check_output(["git", "rev-parse", "HEAD~1"], cwd=3Dself.repo).decode() subprocess.check_output(["git", "tag", "test"], cwd=3Dself.repo) @@ -225,41 +239,48 @@ class TesterTest(PatchewTestCase): =20 def test_tester(self): self.cli_login() - out, err =3D self.check_cli(["tester", "-p", "QEMU,UMEQ", + out, err =3D self.check_cli(["tester", "-p", "QEMU,UMEQ,ALLOW,DENY= ", "--no-wait"]) self.assertIn("Project: QEMU\n", out) self.assertIn("Project: UMEQ\n", out) + self.assertIn("Project: ALLOW\n", out) + self.assertNotIn("Project: DENY\n", out) self.cli_logout() =20 def test_tester_single(self): self.cli_login() - out, err =3D self.check_cli(["tester", "-p", "QEMU,UMEQ", + out, err =3D self.check_cli(["tester", "-p", "QEMU,UMEQ,ALLOW,DENY= ", "--no-wait", "-N", "1"]) self.assertIn("Project: QEMU\n", out) - out, err =3D self.check_cli(["tester", "-p", "QEMU,UMEQ", + out, err =3D self.check_cli(["tester", "-p", "QEMU,UMEQ,ALLOW,DENY= ", "--no-wait", "-N", "1"]) self.assertIn("Project: UMEQ\n", out) - out, err =3D self.check_cli(["tester", "-p", "QEMU,UMEQ", + out, err =3D self.check_cli(["tester", "-p", "QEMU,UMEQ,ALLOW,DENY= ", + "--no-wait", "-N", "1"]) + self.assertIn("Project: ALLOW\n", out) + out, err =3D self.check_cli(["tester", "-p", "QEMU,UMEQ,ALLOW,DENY= ", "--no-wait", "-N", "1"]) self.assertIn("Nothing to test", out) self.cli_logout() =20 def test_tester_project(self): self.cli_login() - out, err =3D self.check_cli(["tester", "-p", "QEMU,UMEQ", + out, err =3D self.check_cli(["tester", "-p", "QEMU,UMEQ,ALLOW,DENY= ", "--no-wait"]) self.assertIn("Project: QEMU\n", out) self.assertIn("Project: UMEQ\n", out) + self.assertIn("Project: ALLOW\n", out) + self.assertNotIn("Project: DENY\n", out) =20 self.p1.git =3D self.repo self.p1.save() self.add_file_and_commit("baz") self.update_head(self.p1) - out, err =3D self.check_cli(["tester", "-p", "QEMU,UMEQ", + out, err =3D self.check_cli(["tester", "-p", "QEMU,UMEQ,ALLOW,DENY= ", "--no-wait", "-N", "1"]) self.assertIn("Project: QEMU\n", out) self.assertIn("'type': 'project'", out) - out, err =3D self.check_cli(["tester", "-p", "QEMU,UMEQ", + out, err =3D self.check_cli(["tester", "-p", "QEMU,UMEQ,ALLOW,DENY= ", "--no-wait", "-N", "1"]) self.assertIn("Nothing to test", out) self.cli_logout() --=20 2.17.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel