[libvirt] [dbus PATCH 2/4] tests: Move some test cases to test_nodedev

Andrea Bolognani abologna at redhat.com
Fri Jul 27 12:37:39 UTC 2018


For whatever reason, a few nodedev-related test cases
have ended up in test_connect instead of the more
appropriate test_nodedev. Move them.

Signed-off-by: Andrea Bolognani <abologna at redhat.com>
---
 tests/test_connect.py | 27 ---------------------------
 tests/test_nodedev.py | 26 ++++++++++++++++++++++++++
 2 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/tests/test_connect.py b/tests/test_connect.py
index f481356..9cc51db 100755
--- a/tests/test_connect.py
+++ b/tests/test_connect.py
@@ -161,19 +161,6 @@ class TestConnect(libvirttest.BaseTestClass):
 
         self.main_loop()
 
-    @pytest.mark.usefixtures("node_device_create")
-    @pytest.mark.parametrize("lookup_method_name,lookup_item", [
-        ("NodeDeviceLookupByName", 'Name'),
-    ])
-    def test_connect_node_device_lookup_by_property(self, lookup_method_name, lookup_item, node_device_create):
-        """Parameterized test for all NodeDeviceLookupBy* API calls of Connect interface
-        """
-        original_path = node_device_create
-        obj = self.bus.get_object('org.libvirt', original_path)
-        prop = obj.Get('org.libvirt.NodeDevice', lookup_item, dbus_interface=dbus.PROPERTIES_IFACE)
-        path = getattr(self.connect, lookup_method_name)(prop)
-        assert original_path == path
-
     @pytest.mark.parametrize("lookup_method_name,lookup_item", [
         ("NetworkLookupByName", 'Name'),
         ("NetworkLookupByUUID", 'UUID'),
@@ -186,20 +173,6 @@ class TestConnect(libvirttest.BaseTestClass):
         path = getattr(self.connect, lookup_method_name)(prop)
         assert original_path == path
 
-    def test_connect_node_device_create_xml(self):
-        def node_device_created(path, event, _detail):
-            if event != libvirttest.NodeDeviceEvent.CREATED:
-                return
-            assert isinstance(path, dbus.ObjectPath)
-            self.loop.quit()
-
-        self.connect.connect_to_signal('NodeDeviceEvent', node_device_created)
-
-        path = self.connect.NodeDeviceCreateXML(xmldata.minimal_node_device_xml, 0)
-        assert isinstance(path, dbus.ObjectPath)
-
-        self.main_loop()
-
     def test_connect_node_get_cpu_stats(self):
         stats = self.connect.NodeGetCPUStats(0, 0)
         assert isinstance(stats, dbus.Dictionary)
diff --git a/tests/test_nodedev.py b/tests/test_nodedev.py
index 082cf0b..c68cb66 100755
--- a/tests/test_nodedev.py
+++ b/tests/test_nodedev.py
@@ -3,11 +3,37 @@
 import dbus
 import libvirttest
 import pytest
+import xmldata
 
 
 class TestNodeDevice(libvirttest.BaseTestClass):
     """ Tests for methods and properties of the NodeDevice interface
     """
+    @pytest.mark.parametrize("lookup_method_name,lookup_item", [
+        ("NodeDeviceLookupByName", 'Name'),
+    ])
+    def test_connect_node_device_lookup_by_property(self, lookup_method_name, lookup_item, node_device_create):
+        """Parameterized test for all NodeDeviceLookupBy* API calls of Connect interface
+        """
+        original_path = node_device_create
+        obj = self.bus.get_object('org.libvirt', original_path)
+        prop = obj.Get('org.libvirt.NodeDevice', lookup_item, dbus_interface=dbus.PROPERTIES_IFACE)
+        path = getattr(self.connect, lookup_method_name)(prop)
+        assert original_path == path
+
+    def test_connect_node_device_create(self):
+        def node_device_created(path, event, _detail):
+            if event != libvirttest.NodeDeviceEvent.CREATED:
+                return
+            assert isinstance(path, dbus.ObjectPath)
+            self.loop.quit()
+
+        self.connect.connect_to_signal('NodeDeviceEvent', node_device_created)
+
+        path = self.connect.NodeDeviceCreateXML(xmldata.minimal_node_device_xml, 0)
+        assert isinstance(path, dbus.ObjectPath)
+
+        self.main_loop()
 
     def test_node_device_destroy(self, node_device_create):
         def node_device_deleted(path, event, _detail):
-- 
2.17.1




More information about the libvir-list mailing list