From nobody Sat Apr 27 17:33:04 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=libvir-list-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=libvir-list-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 1532607016212301.7928580042317; Thu, 26 Jul 2018 05:10:16 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DC68BC04AC4C; Thu, 26 Jul 2018 12:10:12 +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 59138CDFB5; Thu, 26 Jul 2018 12:10:12 +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 CDA8224F60; Thu, 26 Jul 2018 12:10:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6QCA2Na010278 for ; Thu, 26 Jul 2018 08:10:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2D4062026D74; Thu, 26 Jul 2018 12:10:02 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.205.69]) by smtp.corp.redhat.com (Postfix) with ESMTP id BFC0A2026D68 for ; Thu, 26 Jul 2018 12:10:01 +0000 (UTC) From: Katerina Koukiou To: libvirt-list@redhat.com Date: Thu, 26 Jul 2018 14:09:57 +0200 Message-Id: <20180726120958.17252-2-kkoukiou@redhat.com> In-Reply-To: <20180726120958.17252-1-kkoukiou@redhat.com> References: <20180726120958.17252-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 1/2] tests: {interface, node_device}_create should be used as setup fixtures X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 26 Jul 2018 12:10:15 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" * node_device_create was a fixture but we were calling it as normal functio= n, thus it got triggered twice. * interface_create was not a fixture. This patch makes sure that the setup work these two functions are doing, wi= ll run before the actual test call phase. Signed-off-by: Katerina Koukiou Reviewed-by: J=EF=BF=BDn Tomko --- tests/libvirttest.py | 1 + tests/test_connect.py | 9 +++++---- tests/test_interface.py | 22 ++++++++++++---------- tests/test_nodedev.py | 16 ++++++++-------- 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/tests/libvirttest.py b/tests/libvirttest.py index 9db6e0a..7a75ff3 100644 --- a/tests/libvirttest.py +++ b/tests/libvirttest.py @@ -71,6 +71,7 @@ class BaseTestClass(): if self.timeout: raise TimeoutError() =20 + @pytest.fixture def interface_create(self): """ Fixture to define dummy interface on the test driver =20 diff --git a/tests/test_connect.py b/tests/test_connect.py index 042c568..bb2d767 100755 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -88,14 +88,15 @@ class TestConnect(libvirttest.BaseTestClass): path =3D self.connect.InterfaceDefineXML(xmldata.minimal_interface= _xml, 0) assert isinstance(path, dbus.ObjectPath) =20 + @pytest.mark.usefixtures("interface_create") @pytest.mark.parametrize("lookup_method_name,lookup_item", [ ("InterfaceLookupByName", 'Name'), ("InterfaceLookupByMAC", 'MAC'), ]) - def test_connect_interface_lookup_by_property(self, lookup_method_name= , lookup_item): + def test_connect_interface_lookup_by_property(self, lookup_method_name= , lookup_item, interface_create): """Parameterized test for all InterfaceLookupBy* API calls of Conn= ect interface """ - original_path,_ =3D self.interface_create() + original_path,_ =3D interface_create obj =3D self.bus.get_object('org.libvirt', original_path) prop =3D obj.Get('org.libvirt.Interface', lookup_item, dbus_interf= ace=3Ddbus.PROPERTIES_IFACE) path =3D getattr(self.connect, lookup_method_name)(prop) @@ -164,10 +165,10 @@ class TestConnect(libvirttest.BaseTestClass): @pytest.mark.parametrize("lookup_method_name,lookup_item", [ ("NodeDeviceLookupByName", 'Name'), ]) - def test_connect_node_device_lookup_by_property(self, lookup_method_na= me, lookup_item): + def test_connect_node_device_lookup_by_property(self, lookup_method_na= me, lookup_item, node_device_create): """Parameterized test for all NodeDeviceLookupBy* API calls of Con= nect interface """ - original_path =3D self.node_device_create() + original_path =3D node_device_create obj =3D self.bus.get_object('org.libvirt', original_path) prop =3D obj.Get('org.libvirt.NodeDevice', lookup_item, dbus_inter= face=3Ddbus.PROPERTIES_IFACE) path =3D getattr(self.connect, lookup_method_name)(prop) diff --git a/tests/test_interface.py b/tests/test_interface.py index 9503eef..bcda8d5 100755 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -2,33 +2,35 @@ =20 import dbus import libvirttest +import pytest =20 +@pytest.mark.usefixtures("interface_create") class TestInterface(libvirttest.BaseTestClass): """ Tests for methods and properties of the Interface interface """ =20 - def test_interface_undefine(self): - _,interface_obj =3D self.interface_create() + def test_interface_undefine(self, interface_create): + _,interface_obj =3D interface_create interface_obj.Destroy(0) interface_obj.Undefine() =20 - def test_interface_destroy(self): - _,interface_obj =3D self.interface_create() + def test_interface_destroy(self, interface_create): + _,interface_obj =3D interface_create interface_obj.Destroy(0) =20 - def test_interface_create(self): - _,interface_obj =3D self.interface_create() + def test_interface_create(self, interface_create): + _,interface_obj =3D interface_create interface_obj.Destroy(0) interface_obj.Create(0) =20 - def test_interface_get_xml_description(self): - _,interface_obj =3D self.interface_create() + def test_interface_get_xml_description(self, interface_create): + _,interface_obj =3D interface_create assert isinstance(interface_obj.GetXMLDesc(0), dbus.String) =20 - def test_interface_properties_type(self): + def test_interface_properties_type(self, interface_create): """ Ensure correct return type for Interface properties """ - test_interface_path,_ =3D self.interface_create() + test_interface_path,_ =3D interface_create obj =3D self.bus.get_object('org.libvirt', test_interface_path) props =3D obj.GetAll('org.libvirt.Interface', dbus_interface=3Ddbu= s.PROPERTIES_IFACE) assert isinstance(props['Name'], dbus.String) diff --git a/tests/test_nodedev.py b/tests/test_nodedev.py index 6aa6211..22c8d60 100755 --- a/tests/test_nodedev.py +++ b/tests/test_nodedev.py @@ -10,7 +10,7 @@ class TestNodeDevice(libvirttest.BaseTestClass): """ Tests for methods and properties of the NodeDevice interface """ =20 - def test_node_device_destroy(self): + def test_node_device_destroy(self, node_device_create): def node_device_deleted(path, event, _detail): if event !=3D libvirttest.NodeDeviceEvent.DELETED: return @@ -19,29 +19,29 @@ class TestNodeDevice(libvirttest.BaseTestClass): =20 self.connect.connect_to_signal('NodeDeviceEvent', node_device_dele= ted) =20 - test_node_device_path =3D self.node_device_create() + test_node_device_path =3D node_device_create obj =3D self.bus.get_object('org.libvirt', test_node_device_path) interface_obj =3D dbus.Interface(obj, 'org.libvirt.NodeDevice') interface_obj.Destroy() =20 self.main_loop() =20 - def test_node_device_get_xml_description(self): - test_node_device_path =3D self.node_device_create() + def test_node_device_get_xml_description(self, node_device_create): + test_node_device_path =3D node_device_create obj =3D self.bus.get_object('org.libvirt', test_node_device_path) interface_obj =3D dbus.Interface(obj, 'org.libvirt.NodeDevice') assert isinstance(interface_obj.GetXMLDesc(0), dbus.String) =20 - def test_node_device_list_caps(self): - test_node_device_path =3D self.node_device_create() + def test_node_device_list_caps(self, node_device_create): + test_node_device_path =3D node_device_create obj =3D self.bus.get_object('org.libvirt', test_node_device_path) interface_obj =3D dbus.Interface(obj, 'org.libvirt.NodeDevice') assert isinstance(interface_obj.ListCaps(), dbus.Array) =20 - def test_node_device_properties_type(self): + def test_node_device_properties_type(self, node_device_create): """ Ensure correct return type for NodeDevice properties """ - test_node_device_path =3D self.node_device_create() + test_node_device_path =3D node_device_create obj =3D self.bus.get_object('org.libvirt', test_node_device_path) props =3D obj.GetAll('org.libvirt.NodeDevice', dbus_interface=3Ddb= us.PROPERTIES_IFACE) assert isinstance(props['Name'], dbus.String) --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 27 17:33:04 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=libvir-list-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=libvir-list-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 1532607019421970.461555897928; Thu, 26 Jul 2018 05:10:19 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 11024308A96F; Thu, 26 Jul 2018 12:10:18 +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 BE3415F90D; Thu, 26 Jul 2018 12:10:17 +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 6521024F63; Thu, 26 Jul 2018 12:10:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6QCA4A1010287 for ; Thu, 26 Jul 2018 08:10:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3CF772026D74; Thu, 26 Jul 2018 12:10:04 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.205.69]) by smtp.corp.redhat.com (Postfix) with ESMTP id 829A22026D68 for ; Thu, 26 Jul 2018 12:10:02 +0000 (UTC) From: Katerina Koukiou To: libvirt-list@redhat.com Date: Thu, 26 Jul 2018 14:09:58 +0200 Message-Id: <20180726120958.17252-3-kkoukiou@redhat.com> In-Reply-To: <20180726120958.17252-1-kkoukiou@redhat.com> References: <20180726120958.17252-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 2/2] tests: fix all coding style issues to comply with pep8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 26 Jul 2018 12:10:18 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou --- tests/test_connect.py | 2 +- tests/test_domain.py | 5 +++-- tests/test_interface.py | 11 ++++++----- tests/test_network.py | 8 ++++---- tests/test_storage.py | 1 + 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/tests/test_connect.py b/tests/test_connect.py index bb2d767..f481356 100755 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -96,7 +96,7 @@ class TestConnect(libvirttest.BaseTestClass): def test_connect_interface_lookup_by_property(self, lookup_method_name= , lookup_item, interface_create): """Parameterized test for all InterfaceLookupBy* API calls of Conn= ect interface """ - original_path,_ =3D interface_create + original_path, _ =3D interface_create obj =3D self.bus.get_object('org.libvirt', original_path) prop =3D obj.Get('org.libvirt.Interface', lookup_item, dbus_interf= ace=3Ddbus.PROPERTIES_IFACE) path =3D getattr(self.connect, lookup_method_name)(prop) diff --git a/tests/test_domain.py b/tests/test_domain.py index b9a6d33..96b282c 100755 --- a/tests/test_domain.py +++ b/tests/test_domain.py @@ -5,6 +5,7 @@ import libvirttest =20 DBUS_EXCEPTION_MISSING_FUNCTION =3D 'this function is not supported by the= connection driver' =20 + class TestDomain(libvirttest.BaseTestClass): def test_api(self): obj, domain =3D self.get_test_domain() @@ -153,8 +154,8 @@ class TestDomain(libvirttest.BaseTestClass): def test_domain_vcpu_pin_info(self): obj, domain =3D self.get_test_domain() pinInfo_expected =3D [ - [ True, True, True, True, True, True, True, True ], - [ True, True, True, True, True, True, True, True ] + [True, True, True, True, True, True, True, True], + [True, True, True, True, True, True, True, True] ] pinInfo =3D domain.GetVcpuPinInfo(0) assert pinInfo =3D=3D pinInfo_expected diff --git a/tests/test_interface.py b/tests/test_interface.py index bcda8d5..38a1cc1 100755 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -4,33 +4,34 @@ import dbus import libvirttest import pytest =20 + @pytest.mark.usefixtures("interface_create") class TestInterface(libvirttest.BaseTestClass): """ Tests for methods and properties of the Interface interface """ =20 def test_interface_undefine(self, interface_create): - _,interface_obj =3D interface_create + _, interface_obj =3D interface_create interface_obj.Destroy(0) interface_obj.Undefine() =20 def test_interface_destroy(self, interface_create): - _,interface_obj =3D interface_create + _, interface_obj =3D interface_create interface_obj.Destroy(0) =20 def test_interface_create(self, interface_create): - _,interface_obj =3D interface_create + _, interface_obj =3D interface_create interface_obj.Destroy(0) interface_obj.Create(0) =20 def test_interface_get_xml_description(self, interface_create): - _,interface_obj =3D interface_create + _, interface_obj =3D interface_create assert isinstance(interface_obj.GetXMLDesc(0), dbus.String) =20 def test_interface_properties_type(self, interface_create): """ Ensure correct return type for Interface properties """ - test_interface_path,_ =3D interface_create + test_interface_path, _ =3D interface_create obj =3D self.bus.get_object('org.libvirt', test_interface_path) props =3D obj.GetAll('org.libvirt.Interface', dbus_interface=3Ddbu= s.PROPERTIES_IFACE) assert isinstance(props['Name'], dbus.String) diff --git a/tests/test_network.py b/tests/test_network.py index 11418cb..2e3a8f0 100755 --- a/tests/test_network.py +++ b/tests/test_network.py @@ -25,7 +25,7 @@ class TestNetwork(libvirttest.BaseTestClass): assert isinstance(props['UUID'], dbus.String) =20 def test_network_autostart(self): - _,test_network =3D self.get_test_network() + _, test_network =3D self.get_test_network() interface_obj =3D dbus.Interface(test_network, 'org.libvirt.Networ= k') autostart_expected =3D True interface_obj.Set('org.libvirt.Network', 'Autostart', autostart_ex= pected, dbus_interface=3Ddbus.PROPERTIES_IFACE) @@ -41,7 +41,7 @@ class TestNetwork(libvirttest.BaseTestClass): =20 self.connect.connect_to_signal('NetworkEvent', domain_started) =20 - _,test_network =3D self.get_test_network() + _, test_network =3D self.get_test_network() interface_obj =3D dbus.Interface(test_network, 'org.libvirt.Networ= k') interface_obj.Destroy() interface_obj.Create() @@ -64,7 +64,7 @@ class TestNetwork(libvirttest.BaseTestClass): self.main_loop() =20 def test_network_get_xml_description(self): - _,test_network =3D self.get_test_network() + _, test_network =3D self.get_test_network() interface_obj =3D dbus.Interface(test_network, 'org.libvirt.Networ= k') assert isinstance(interface_obj.GetXMLDesc(0), dbus.String) =20 @@ -77,7 +77,7 @@ class TestNetwork(libvirttest.BaseTestClass): =20 self.connect.connect_to_signal('NetworkEvent', domain_undefined) =20 - _,test_network =3D self.get_test_network() + _, test_network =3D self.get_test_network() interface_obj =3D dbus.Interface(test_network, 'org.libvirt.Networ= k') interface_obj.Destroy() interface_obj.Undefine() diff --git a/tests/test_storage.py b/tests/test_storage.py index 63ecf91..631e107 100755 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -4,6 +4,7 @@ import dbus import libvirttest import pytest =20 + class TestStoragePool(libvirttest.BaseTestClass): def test_storage_pool_autostart(self): _, test_storage_pool =3D self.get_test_storage_pool() --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list