|
| 1 | +"""Module for unittesting the core pci module""" |
| 2 | + |
| 3 | +import unittest |
| 4 | +from hwinfo.pci import * |
| 5 | + |
| 6 | +class TestPCIDeviceObject(unittest.TestCase): |
| 7 | + |
| 8 | + DEVICE_REC = { |
| 9 | + 'pci_device_bus_id': '02:00.0', |
| 10 | + 'pci_device_type_id': '0200', |
| 11 | + 'pci_device_type_name': 'Ethernet controller', |
| 12 | + 'pci_vendor_name': 'Broadcom Corporation', |
| 13 | + 'pci_vendor_id': '14e4', |
| 14 | + 'pci_device_id': '163b', |
| 15 | + 'pci_device_name': 'NetXtreme II BCM5716 Gigabit Ethernet', |
| 16 | + 'pci_subvendor_name': 'Dell', |
| 17 | + 'pci_subvendor_id': '1028', |
| 18 | + 'pci_subdevice_name': 'Device', |
| 19 | + 'pci_subdevice_id': '02a3', |
| 20 | + } |
| 21 | + |
| 22 | + def setUp(self): |
| 23 | + self.device = PCIDevice(self.DEVICE_REC) |
| 24 | + |
| 25 | + def test_get_device_name(self): |
| 26 | + name = self.device.get_device_name() |
| 27 | + self.assertEqual(name, 'NetXtreme II BCM5716 Gigabit Ethernet') |
| 28 | + |
| 29 | + def test_get_vendor_name(self): |
| 30 | + name = self.device.get_vendor_name() |
| 31 | + self.assertEqual(name, 'Broadcom Corporation') |
| 32 | + |
| 33 | + def test_get_vendor_id(self): |
| 34 | + name = self.device.get_vendor_id() |
| 35 | + self.assertEqual(name, '14e4') |
| 36 | + |
| 37 | + def test_get_subdevice_name(self): |
| 38 | + name = self.device.get_subdevice_name() |
| 39 | + self.assertEqual(name, 'unknown [02a3]') |
| 40 | + |
| 41 | + def test_get_subvendor_name(self): |
| 42 | + name = self.device.get_subvendor_name() |
| 43 | + self.assertEqual(name, 'Dell') |
| 44 | + |
| 45 | + def test_get_subvendor_id(self): |
| 46 | + name = self.device.get_subvendor_id() |
| 47 | + self.assertEqual(name, '1028') |
| 48 | + |
| 49 | + def test_get_device_id(self): |
| 50 | + name = self.device.get_device_id() |
| 51 | + self.assertEqual(name, '163b') |
| 52 | + |
| 53 | + def test_get_subdevice_id(self): |
| 54 | + name = self.device.get_subdevice_id() |
| 55 | + self.assertEqual(name, '02a3') |
| 56 | + |
| 57 | + def test_get_pci_id(self): |
| 58 | + pciid = self.device.get_pci_id() |
| 59 | + self.assertEqual(pciid, '14e4:163b 1028:02a3') |
| 60 | + |
| 61 | + def test_is_subdevice(self): |
| 62 | + self.assertTrue(self.device.is_subdevice()) |
| 63 | + |
| 64 | + def test_get_device_info(self): |
| 65 | + info = self.device.get_info() |
| 66 | + self.assertEqual(info, 'Dell unknown [02a3] (Broadcom Corporation NetXtreme II BCM5716 Gigabit Ethernet)') |
0 commit comments