diff options
author | Cole Robinson <crobinso@redhat.com> | 2013-09-22 18:13:24 -0400 |
---|---|---|
committer | Cole Robinson <crobinso@redhat.com> | 2013-09-23 08:25:20 -0400 |
commit | b690557a53bc46bbcc9ad0750e93e4eeef3acaa9 (patch) | |
tree | 7966a50d7435f97034947892902ad41e3e99b28c /tests/nodedev.py | |
parent | 1c0475feff1d6dc657778ecaba5a7e305ee3cac5 (diff) | |
download | virt-manager-b690557a53bc46bbcc9ad0750e93e4eeef3acaa9.tar.gz |
Convert NodeDevice to XMLBuilder
Diffstat (limited to 'tests/nodedev.py')
-rw-r--r-- | tests/nodedev.py | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/tests/nodedev.py b/tests/nodedev.py index ce0c7538..1aeea7d9 100644 --- a/tests/nodedev.py +++ b/tests/nodedev.py @@ -17,7 +17,7 @@ import os.path import unittest -from virtinst import NodeDeviceParser as nodeparse +from virtinst import NodeDevice from virtinst import VirtualHostDevice from tests import utils @@ -42,15 +42,20 @@ class TestNodeDev(unittest.TestCase): def _nodeDevFromName(self, devname): node = conn.nodeDeviceLookupByName(devname) xml = node.XMLDesc(0) - return nodeparse.parse(xml) + return NodeDevice.parse(conn, xml) def _testCompare(self, devname, vals, devxml=None): if devxml: - dev = nodeparse.parse(devxml) + dev = NodeDevice.parse(conn, devxml) else: dev = self._nodeDevFromName(devname) for attr in vals.keys(): + expect = vals[attr] + actual = getattr(dev, attr) + if expect != actual: + raise AssertionError("devname=%s attribute=%s did not match:\n" + "expect=%s\nactual=%s" % (devname, attr, expect, actual)) self.assertEqual(vals[attr], getattr(dev, attr)) def _testNode2DeviceCompare(self, nodename, devfile, @@ -70,14 +75,14 @@ class TestNodeDev(unittest.TestCase): "hw_uuid": "97e80381-494f-11cb-8e0e-cbc168f7d753", "fw_vendor": "LENOVO", "fw_version": "7LET51WW (1.21 )", "fw_date": "08/22/2007", - "device_type": nodeparse.CAPABILITY_TYPE_SYSTEM, + "device_type": NodeDevice.CAPABILITY_TYPE_SYSTEM, "name": "computer", "parent": None} self._testCompare(devname, vals) def testNetDevice1(self): devname = "net_00_1c_25_10_b1_e4" vals = {"name": "net_00_1c_25_10_b1_e4", "parent": "pci_8086_1049", - "device_type": nodeparse.CAPABILITY_TYPE_NET, + "device_type": NodeDevice.CAPABILITY_TYPE_NET, "interface": "eth0", "address": "00:1c:25:10:b1:e4", "capability_type": "80203"} self._testCompare(devname, vals) @@ -85,7 +90,7 @@ class TestNodeDev(unittest.TestCase): def testNetDevice2(self): devname = "net_00_1c_bf_04_29_a4" vals = {"name": "net_00_1c_bf_04_29_a4", "parent": "pci_8086_4227", - "device_type": nodeparse.CAPABILITY_TYPE_NET, + "device_type": NodeDevice.CAPABILITY_TYPE_NET, "interface": "wlan0", "address": "00:1c:bf:04:29:a4", "capability_type": "80211"} self._testCompare(devname, vals) @@ -93,7 +98,7 @@ class TestNodeDev(unittest.TestCase): def testPCIDevice1(self): devname = "pci_1180_592" vals = {"name": "pci_1180_592", "parent": "pci_8086_2448", - "device_type": nodeparse.CAPABILITY_TYPE_PCI, + "device_type": NodeDevice.CAPABILITY_TYPE_PCI, "domain": "0", "bus": "21", "slot": "0", "function": "4", "product_id": "0x0592", "vendor_id": "0x1180", "product_name": "R5C592 Memory Stick Bus Host Adapter", @@ -103,7 +108,7 @@ class TestNodeDev(unittest.TestCase): def testPCIDevice2(self): devname = "pci_8086_1049" vals = {"name": "pci_8086_1049", "parent": "computer", - "device_type": nodeparse.CAPABILITY_TYPE_PCI, + "device_type": NodeDevice.CAPABILITY_TYPE_PCI, "domain": "0", "bus": "0", "slot": "25", "function": "0", "product_id": "0x1049", "vendor_id": "0x8086", "product_name": "82566MM Gigabit Network Connection", @@ -114,7 +119,7 @@ class TestNodeDev(unittest.TestCase): devname = "usb_device_781_5151_2004453082054CA1BEEE" vals = {"name": "usb_device_781_5151_2004453082054CA1BEEE", "parent": "usb_device_1d6b_2_0000_00_1a_7", - "device_type": nodeparse.CAPABILITY_TYPE_USBDEV, + "device_type": NodeDevice.CAPABILITY_TYPE_USBDEV, "bus": "1", "device": "4", "product_id": '0x5151', "vendor_id": '0x0781', "vendor_name": "SanDisk Corp.", @@ -125,7 +130,7 @@ class TestNodeDev(unittest.TestCase): devname = "usb_device_483_2016_noserial" vals = {"name": "usb_device_483_2016_noserial", "parent": "usb_device_1d6b_1_0000_00_1a_0", - "device_type": nodeparse.CAPABILITY_TYPE_USBDEV, + "device_type": NodeDevice.CAPABILITY_TYPE_USBDEV, "bus": "3", "device": "2", "product_id": '0x2016', "vendor_id": '0x0483', "vendor_name": "SGS Thomson Microelectronics", @@ -136,21 +141,21 @@ class TestNodeDev(unittest.TestCase): devname = "storage_serial_SATA_WDC_WD1600AAJS__WD_WCAP95119685" vals = {"name": "storage_serial_SATA_WDC_WD1600AAJS__WD_WCAP95119685", "parent": "pci_8086_27c0_scsi_host_scsi_device_lun0", - "device_type": nodeparse.CAPABILITY_TYPE_STORAGE, + "device_type": NodeDevice.CAPABILITY_TYPE_STORAGE, "block": "/dev/sda", "bus": "scsi", "drive_type": "disk", "model": "WDC WD1600AAJS-2", "vendor": "ATA", "size": 160041885696, "removable": False, - "hotpluggable": False, "media_available": False, - "media_size": 0, "media_label": None} + "hotpluggable": False, "media_available": None, + "media_size": None, "media_label": None} self._testCompare(devname, vals) def testStorageDevice2(self): devname = "storage_serial_SanDisk_Cruzer_Micro_2004453082054CA1BEEE_0_0" vals = {"name": "storage_serial_SanDisk_Cruzer_Micro_2004453082054CA1BEEE_0_0", "parent": "usb_device_781_5151_2004453082054CA1BEEE_if0_scsi_host_0_scsi_device_lun0", - "device_type": nodeparse.CAPABILITY_TYPE_STORAGE, + "device_type": NodeDevice.CAPABILITY_TYPE_STORAGE, "block": "/dev/sdb", "bus": "usb", "drive_type": "disk", - "model": "Cruzer Micro", "vendor": "SanDisk", "size": 0, + "model": "Cruzer Micro", "vendor": "SanDisk", "size": None, "removable": True, "hotpluggable": True, "media_available": True, "media_size": 12345678} self._testCompare(devname, vals) @@ -159,7 +164,7 @@ class TestNodeDev(unittest.TestCase): devname = "usb_device_1d6b_1_0000_00_1d_1_if0" vals = {"name": "usb_device_1d6b_1_0000_00_1d_1_if0", "parent": "usb_device_1d6b_1_0000_00_1d_1", - "device_type": nodeparse.CAPABILITY_TYPE_USBBUS, + "device_type": NodeDevice.CAPABILITY_TYPE_USBBUS, "number": "0", "classval": "9", "subclass": "0", "protocol": "0"} self._testCompare(devname, vals) @@ -168,14 +173,14 @@ class TestNodeDev(unittest.TestCase): devname = "pci_8086_2829_scsi_host_1" vals = {"name": "pci_8086_2829_scsi_host_1", "parent": "pci_8086_2829", - "device_type": nodeparse.CAPABILITY_TYPE_SCSIBUS, + "device_type": NodeDevice.CAPABILITY_TYPE_SCSIBUS, "host": "2"} self._testCompare(devname, vals) def testNPIV(self): devname = "pci_10df_fe00_0_scsi_host" vals = {"name": "pci_10df_fe00_0_scsi_host", - "device_type": nodeparse.CAPABILITY_TYPE_SCSIBUS, + "device_type": NodeDevice.CAPABILITY_TYPE_SCSIBUS, "host": "4", "fc_host": True, "vport_ops" : True, "wwnn": "20000000c9848141", "wwpn": "10000000c9848141"} self._testCompare(devname, vals) |