File: test_nodedev.py

package info (click to toggle)
libvirt-dbus 1.4.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 888 kB
  • sloc: ansic: 8,558; xml: 1,588; python: 926; sh: 149; makefile: 19
file content (50 lines) | stat: -rwxr-xr-x 1,972 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python3

import dbus
import libvirttest


class TestNodeDevice(libvirttest.BaseTestClass):
    """ Tests for methods and properties of the NodeDevice interface
    """

    def test_node_device_destroy(self, node_device_create):
        def node_device_deleted(path, event, _detail):
            if event != libvirttest.NodeDeviceEvent.DELETED:
                return
            assert isinstance(path, dbus.ObjectPath)
            self.loop.quit()

        self.connect.connect_to_signal('NodeDeviceEvent', node_device_deleted)

        test_node_device_path = node_device_create
        obj = self.bus.get_object('org.libvirt', test_node_device_path)
        interface_obj = dbus.Interface(obj, 'org.libvirt.NodeDevice')
        interface_obj.Destroy()

        self.main_loop()

    def test_node_device_get_xml_description(self, node_device_create):
        test_node_device_path = node_device_create
        obj = self.bus.get_object('org.libvirt', test_node_device_path)
        interface_obj = dbus.Interface(obj, 'org.libvirt.NodeDevice')
        assert isinstance(interface_obj.GetXMLDesc(0), dbus.String)

    def test_node_device_list_caps(self, node_device_create):
        test_node_device_path = node_device_create
        obj = self.bus.get_object('org.libvirt', test_node_device_path)
        interface_obj = dbus.Interface(obj, 'org.libvirt.NodeDevice')
        assert isinstance(interface_obj.ListCaps(), dbus.Array)

    def test_node_device_properties_type(self, node_device_create):
        """ Ensure correct return type for NodeDevice properties
        """
        test_node_device_path = node_device_create
        obj = self.bus.get_object('org.libvirt', test_node_device_path)
        props = obj.GetAll('org.libvirt.NodeDevice', dbus_interface=dbus.PROPERTIES_IFACE)
        assert isinstance(props['Name'], dbus.String)
        assert isinstance(props['Parent'], dbus.String)


if __name__ == '__main__':
    libvirttest.run()