'Ensure we can extract PCI devices info.'

def testPCIDevicesInfoParser(self):

    test_data1 = {'/sys/bus/pci/devices/0000:00:01.0/vendor': '0x0e00\n', '/sys/bus/pci/devices/0000:00:01.0/class': '0x060400\n', '/sys/bus/pci/devices/0000:00:01.0/device': '0x0e02\n', '/sys/bus/pci/devices/0000:00:01.0/config': '0200'}
    device_1 = rdf_client.PCIDevice(domain=0, bus=0, device=1, function=0, class_id='0x060400', vendor='0x0e00', vendor_device_id='0x0e02', config='0200')
    parsed_results = self._ParsePCIDeviceTestData(test_data1)
    self._MatchPCIDeviceResultToExpected(parsed_results, [device_1])
    bytes2 = bytearray([234, 232, 231, 188, 122, 132, 145])
    test_data2 = {'/sys/bus/pci/devices/0000:00:00.0/vendor': '0x8086\n', '/sys/bus/pci/devices/0000:00:00.0/class': '0x060000\n', '/sys/bus/pci/devices/0000:00:00.0/device': '0x0e00\n', '/sys/bus/pci/devices/0000:00:00.0/config': bytes2}
    device_2 = rdf_client.PCIDevice(domain=0, bus=0, device=0, function=0, class_id='0x060000', vendor='0x8086', vendor_device_id='0x0e00', config='\xea\xe8\xe7\xbcz\x84\x91')
    parsed_results = self._ParsePCIDeviceTestData(test_data2)
    self._MatchPCIDeviceResultToExpected(parsed_results, [device_2])
    test_data3 = {'/sys/bus/pci/devices/0000:00:03.0/vendor': '0x0e00\n', '/sys/bus/pci/devices/0000:00:03.0/config': '0030'}
    device_3 = rdf_client.PCIDevice(domain=0, bus=0, device=3, function=0, vendor='0x0e00', config='0030')
    parsed_results = self._ParsePCIDeviceTestData(test_data3)
    self._MatchPCIDeviceResultToExpected(parsed_results, [device_3])
    test_data4 = {'/sys/bus/pci/devices/0000:00:05.0/vendor': '0x0e00\n', '/sys/bus/pci/devices/0000:00:05.0/class': '0x060400\n', '/sys/bus/pci/devices/0000:00:05.0/device': '0x0e02\n', '/sys/bus/pci/devices/0000:00:05.0/config': '0200', '/sys/bus/pci/devices/crazyrandomfile/test1': 'test1', '/sys/bus/pci/devices/::./test2': 'test2', '/sys/bus/pci/devices/00:5.0/test3': 'test3'}
    device_4 = rdf_client.PCIDevice(domain=0, bus=0, device=5, function=0, class_id='0x060400', vendor='0x0e00', vendor_device_id='0x0e02', config='0200')
    parsed_results = self._ParsePCIDeviceTestData(test_data4)
    self._MatchPCIDeviceResultToExpected(parsed_results, [device_4])
    combined_data = test_data1.copy()
    combined_data.update(test_data3)
    combined_data.update(test_data4)
    combined_data.update(test_data2)
    parsed_results = self._ParsePCIDeviceTestData(combined_data)
    self._MatchPCIDeviceResultToExpected(parsed_results, [device_1, device_4, device_2, device_3])
