From nobody Fri Oct 25 19:31:16 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=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 1521898658442220.99878566593657; Sat, 24 Mar 2018 06:37:38 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 635EC4E8A8; Sat, 24 Mar 2018 13:37:37 +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 41F5B6090A; Sat, 24 Mar 2018 13:37:37 +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 336544CA98; Sat, 24 Mar 2018 13:37:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2ODbaM6031736 for ; Sat, 24 Mar 2018 09:37:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 364845E1C2; Sat, 24 Mar 2018 13:37:36 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2E75E5E1C1 for ; Sat, 24 Mar 2018 13:37:34 +0000 (UTC) Received: from mail-wm0-f43.google.com (mail-wm0-f43.google.com [74.125.82.43]) (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 AB6BC36809 for ; Sat, 24 Mar 2018 13:37:32 +0000 (UTC) Received: by mail-wm0-f43.google.com with SMTP id l9so8111566wmh.2 for ; Sat, 24 Mar 2018 06:37:32 -0700 (PDT) Received: from donizetti.lan (94-36-194-48.adsl-ull.clienti.tiscali.it. [94.36.194.48]) by smtp.gmail.com with ESMTPSA id i78sm3854257wmc.32.2018.03.24.06.37.29 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 24 Mar 2018 06:37:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=ieHTPVhZpYmsCwqpR6nXsoPD2g9E5yoN91g5Y7BDdi0=; b=p9SmoUfZJYUitN0/Nh9u+SFhCG+z4c6mvziLpVHjNW6sZDiewCGK5nSVVdYifJWaxk Cfc0HRdvdH2j2URuuREQEogzH0FFDbn5UxwS/Pm5ELcvMN8bfqOzauMTB/ZCV/P6kjuk ytwFtJcbJM6ni+lYK7SjvjIwQL8yJi3nJrouARiaZXAidPjQr88ooHNJifsHWY6bjafU 3sUWfZhbkOoTrjIqtomo2htSGQr9KZazTuWmnHz9J5L5pwHqMbWznEQ651KYq6A7/LDn 4/mEHezb5nuWtGEHDCOsxFmScCl8cZC/rUTHk5C2Qc+c7admp2zBJAR4sGrwYctSI+iT SbJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=ieHTPVhZpYmsCwqpR6nXsoPD2g9E5yoN91g5Y7BDdi0=; b=CI07AE1XQFeQAG68hM7/4AqbMpe3F2zSbhzkqUHivAIzGska/dK1Bi2IRYbsWIVQ7X B9LZQLfeGSrLvAq3mdbkqb9w8AmGiYQOSqssCjAOoRrXtv8RmtqXwvWPjUyagYe3ioW9 sDu/7dLDUMRSwmMamqu5ekgS1Lf/6X7Mba+7Zpg+pPPQSXxj4TPJEEvQUn7rFc30BMEb KmWfElGzwMyu7T0eY3DJCl+17DnQk2TvPLrQcE4t0jfaJjmz0rpzTVA6VateuwKkf0iA mlhwjUpzmAtYZtU2S2/XFPx1hyNgK9P+9B7BXr/u6lhocAQERjT5K7l9VWQPY+WXvMPH m0mg== X-Gm-Message-State: AElRT7F/K9D7W+8KF/2uL3nfXiMAQEyFOcsKm4R3gfG5NimeVWW+FHP3 BnKg6eboU06TNRJTswoBRPyGVk3g X-Google-Smtp-Source: AG47ELtwcedV6bln3rtVDRJAUr7thuJyxJxF9uFMjnGvuslMQsRIOSGgCCQeJEYtlqeYIt2IDyhJLQ== X-Received: by 10.28.220.130 with SMTP id t124mr11686807wmg.60.1521898650844; Sat, 24 Mar 2018 06:37:30 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Sat, 24 Mar 2018 14:37:18 +0100 Message-Id: <20180324133719.6030-8-pbonzini@redhat.com> In-Reply-To: <20180324133719.6030-1-pbonzini@redhat.com> References: <20180324133719.6030-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sat, 24 Mar 2018 13:37:33 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sat, 24 Mar 2018 13:37:33 +0000 (UTC) for IP:'74.125.82.43' DOMAIN:'mail-wm0-f43.google.com' HELO:'mail-wm0-f43.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.469 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 74.125.82.43 mail-wm0-f43.google.com 74.125.82.43 mail-wm0-f43.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 7/8] testing: refactor tests introducing a common superclass TestingTestCase 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sat, 24 Mar 2018 13:37:37 +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" --- tests/test_testing.py | 85 +++++++++++++++++++++++++++++++++--------------= ---- 1 file changed, 56 insertions(+), 29 deletions(-) diff --git a/tests/test_testing.py b/tests/test_testing.py index a8345d8..e525e1d 100755 --- a/tests/test_testing.py +++ b/tests/test_testing.py @@ -8,6 +8,7 @@ # This work is licensed under the MIT License. Please see the LICENSE fil= e or # http://opensource.org/licenses/MIT. =20 +import abc import sys import os import subprocess @@ -24,7 +25,7 @@ def create_test(project, name): project.set_property(prefix + "users", "") project.set_property(prefix + "tester", "") =20 -class TestingTest(PatchewTestCase): +class TestingTestCase(PatchewTestCase, metaclass=3Dabc.ABCMeta): =20 def setUp(self): self.create_superuser() @@ -33,33 +34,21 @@ class TestingTest(PatchewTestCase): =20 create_test(self.p, "a") =20 - self.cli_login() - self.cli_import('0001-simple-patch.mbox.gz') - self.cli_logout() - - self.msg =3D Message.objects.all()[0] - self.msg.save() - self.msg.set_property("git.repo", "dummy repo") - self.msg.set_property("git.tag", "dummy tag") - self.msg.set_property("git.base", "dummy base") - - def msg_testing_done(self, log=3DNone, **report): + def _do_testing_done(self, obj, log, report): if not 'passed' in report: report['passed'] =3D True - self.msg.set_property("testing.report.tests", report) + obj.set_property("testing.report.tests", report) if log is not None: - self.msg.set_property("testing.log.tests", log) - self.msg.set_property("testing.done", True) - self.msg.set_property("testing.ready", None) + obj.set_property("testing.log.tests", log) + obj.set_property("testing.done", True) + obj.set_property("testing.ready", None) =20 - def msg_testing_report(self, **report): + def do_testing_report(self, **report): self.api_login() r =3D self.api_call("testing-get", project=3D"QEMU", tester=3D"dummy tester", capabilities=3D[]) - self.assertEquals(r['identity']['type'], 'series') - report['project'] =3D r["project"] report['identity'] =3D r["identity"] report['test'] =3D r["test"]["name"] @@ -74,7 +63,15 @@ class TestingTest(PatchewTestCase): report['is_timeout'] =3D False =20 self.api_call("testing-report", **report) - return r['identity']['message-id'] + return r['identity'] + + @abc.abstractmethod + def do_testing_done(self, log=3DNone, **report): + pass + + @abc.abstractmethod + def get_test_result(self, test_name): + pass =20 def test_basic(self): self.api_login() @@ -85,7 +82,7 @@ class TestingTest(PatchewTestCase): self.assertIn("head", td) =20 def test_done(self): - self.msg_testing_done() + self.do_testing_done() self.api_login() td =3D self.api_call("testing-get", project=3D"QEMU", @@ -94,8 +91,8 @@ class TestingTest(PatchewTestCase): self.assertFalse(td) =20 def test_rest_done_success(self): - self.msg_testing_done(log=3D'everything good!', passed=3DTrue) - resp =3D self.api_client.get('%sseries/%s/results/testing.tests/' = % (self.PROJECT_BASE, self.msg.message_id)) + self.do_testing_done(log=3D'everything good!', passed=3DTrue) + resp =3D self.get_test_result('tests') self.assertEquals(resp.data['status'], 'success') self.assertEquals(resp.data['log'], 'everything good!') log =3D self.client.get(resp.data['log_url']) @@ -103,8 +100,8 @@ class TestingTest(PatchewTestCase): self.assertEquals(log.content, b'everything good!') =20 def test_rest_done_failure(self): - self.msg_testing_done(log=3D'sorry no good', passed=3DFalse, rando= m_stuff=3D'xyz') - resp =3D self.api_client.get('%sseries/%s/results/testing.tests/' = % (self.PROJECT_BASE, self.msg.message_id)) + self.do_testing_done(log=3D'sorry no good', passed=3DFalse, random= _stuff=3D'xyz') + resp =3D self.get_test_result('tests') self.assertEquals(resp.data['status'], 'failure') self.assertEquals(resp.data['data']['random_stuff'], 'xyz') self.assertEquals(resp.data['log'], 'sorry no good') @@ -114,8 +111,8 @@ class TestingTest(PatchewTestCase): =20 def test_api_report_success(self): self.api_login() - msgid =3D self.msg_testing_report(log=3D'everything good!', passed= =3DTrue) - resp =3D self.api_client.get('%sseries/%s/results/testing.a/' % (s= elf.PROJECT_BASE, self.msg.message_id)) + self.do_testing_report(log=3D'everything good!', passed=3DTrue) + resp =3D self.get_test_result('a') self.assertEquals(resp.data['data']['is_timeout'], False) self.assertEquals(resp.data['status'], 'success') log =3D self.client.get(resp.data['log_url']) @@ -125,8 +122,8 @@ class TestingTest(PatchewTestCase): =20 def test_api_report_failure(self): self.api_login() - msgid =3D self.msg_testing_report(log=3D'sorry no good', passed=3D= False) - resp =3D self.api_client.get('%sseries/%s/results/testing.a/' % (s= elf.PROJECT_BASE, self.msg.message_id)) + self.do_testing_report(log=3D'sorry no good', passed=3DFalse) + resp =3D self.get_test_result('a') self.assertEquals(resp.data['data']['is_timeout'], False) self.assertEquals(resp.data['status'], 'failure') self.assertEquals(resp.data['log'], 'sorry no good') @@ -134,6 +131,33 @@ class TestingTest(PatchewTestCase): self.assertEquals(log.status_code, 200) self.assertEquals(log.content, b'sorry no good') =20 +class MessageTestingTest(TestingTestCase): + + def setUp(self): + super(MessageTestingTest, self).setUp() + + self.cli_login() + self.cli_import('0001-simple-patch.mbox.gz') + self.cli_logout() + + self.msg =3D Message.objects.all()[0] + self.msg.save() + self.msg.set_property("git.repo", "dummy repo") + self.msg.set_property("git.tag", "dummy tag") + self.msg.set_property("git.base", "dummy base") + + def do_testing_done(self, log=3DNone, **report): + self._do_testing_done(self.msg, log, report) + + def do_testing_report(self, **report): + r =3D super(MessageTestingTest, self).do_testing_report(**report) + self.assertEquals(r['type'], 'series') + return r + + def get_test_result(self, test_name): + return self.api_client.get('%sseries/%s/results/testing.%s/' % ( + self.PROJECT_BASE, self.msg.message= _id, test_name)) + class TesterTest(PatchewTestCase): =20 def setUp(self): @@ -186,5 +210,8 @@ class TesterTest(PatchewTestCase): self.assertIn("Nothing to test", out) self.cli_logout() =20 +# do not run tests on the abstract class +del TestingTestCase + if __name__ =3D=3D '__main__': main() --=20 2.16.2 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel