I changed the name because the device is indeed a PCCard, an I use it also in a new test of translatePciBus(), so I thought that the test data should get a more precise name.
Abel
@@ -1173,7 +1173,7 @@ parser.submission_key, "Unknown bus 'nonsense' for device " + self.UDI_PCCARD_DEVICE)
- def testHALDevice_is_root_device_for_root_device(self):
+ def test_HALDevice_is_root_device_for_root_device(self):
"""Test of HALDevice.is_root_device for the root device."""
devices = [
{
@@ -1195,7 +1195,7 @@ parser.buildDeviceList(parsed_data) self.assertTrue(parser.hal_devices[self.UDI_COMPUTER].is_root_device)
- def testHALDevice_is_root_device_for_non_root_device(self):
+ def test_HALDevice_is_root_device_for_non_root_device(self):
"""Test of HALDevice.is_root_device for a non-root device."""
devices = [
{
Hi Michael,
thanks for your review!
> Great! The addition of the is_root_device property makes the code much launchpad/ scripts/ hwdbsubmissions .py' launchpad/ scripts/ hwdbsubmissions .py 2009-10-15 launchpad/ scripts/ hwdbsubmissions .py 2009-10-15 .pci_subclass storage_ subclass_ hwbus.get( pci_subclass) device( self): csiBus( ) ciBus() root_device: _logWarning( y('info. subsystem' ) device( self): uct(self, type_): root_device: get('DEVTYPE' ) get('SUBSYSTEM' ) device( self): uct(self, type_): root_device: device_ ids[type_ ] root_device: launchpad/ scripts/ tests/test_ hwdb_submission _processing. py' launchpad/ scripts/ tests/test_ hwdb_submission _processing. py launchpad/ scripts/ tests/test_ hwdb_submission _processing. py submission_ key, PCCARD_ DEVICE) is_root_ device_ for_root_ device( self): scsi_controller _no_parent( self):
> more readable.
>
> As usual, just one or two comments below, in particular, one change for which
> I couldn't see the cause...
>
> Thanks!
>
> > === modified file 'lib/canonical/
> > --- lib/canonical/
> 13:22:14 +0000
> > +++ lib/canonical/
> 13:59:33 +0000
> > @@ -1644,7 +1644,7 @@
> > return None
> > pci_subclass = scsi_controller
> > return self.pci_
> > - elif scsi_controller_bus == 'usb':
> > + elif scsi_controller_bus in ('usb', 'usb_interface'):
> > # USB storage devices have the following HAL device hierarchy:
> > # - HAL node for the USB device. info.bus == 'usb_device',
> > # device class == 0, device subclass == 0
> > @@ -1703,6 +1703,12 @@
> > return HWBus.PCI
> >
> > @property
> > + def is_root_
> > + """Return True is this is the root node of all devicese, else
> False.
> > + """
> > + raise NotImplementedError
> > +
> > + @property
> > def raw_bus(self):
> > """Return the device bus as specified by HAL or udev."""
> > raise NotImplementedError
> > @@ -1719,11 +1725,11 @@
> > if result is not None:
> > return result
> >
> > - if device_bus == 'scsi':
> > + if device_bus in ('scsi', 'scsi_device'):
> > return self.translateS
> > elif device_bus == 'pci':
> > return self.translateP
> > - elif self.udi == ROOT_UDI:
> > + elif self.is_
> > # The computer itself. In Hardy, HAL provides no info.bus
> > # for the machine itself; older versions set info.bus to
> > # 'unknown', hence it is better to use the machine's
> > @@ -1731,7 +1737,7 @@
> > return HWBus.SYSTEM
> > else:
> > self.parser.
> > - 'Unknown bus %r for device %s' % (device_bus, self.udi))
> > + 'Unknown bus %r for device %s' % (device_bus,
> self.device_id))
> > return None
> >
> > @property
> > @@ -2275,6 +2281,11 @@
> > return result
> > return self.getPropert
> >
> > + @property
> > + def is_root_
> > + """See `BaseDevice`."""
> > + return self.udi == ROOT_UDI
> > +
> > def getVendorOrProd
> > """Return the vendor or product of this device.
> >
> > @@ -2547,7 +2558,7 @@
> > # DEVTYPE. DEVTYPE is preferable.
> > # The root device has the subsystem/bus value "acpi", which
> > # is a bit nonsensical.
> > - if self.device_id == UDEV_ROOT_PATH:
> > + if self.is_
> > return None
> > properties = self.udev['E']
> > devtype = properties.
> > @@ -2555,6 +2566,11 @@
> > return devtype
> > return properties.
> >
> > + @property
> > + def is_root_
> > + """See `BaseDevice`."""
> > + return self.udev['P'] == UDEV_ROOT_PATH
> > +
> > def getVendorOrProd
> > """Return the vendor or product of this device.
> >
> > @@ -2565,7 +2581,7 @@
> > 'Unexpected value of type_: %r' % type_)
> >
> > bus = self.raw_bus
> > - if self.device_id == UDEV_ROOT_PATH:
> > + if self.is_
> > # udev does not known about any product information for
> > # the root device. We use DMI data instead.
> > return self.root_
> > @@ -2605,7 +2621,7 @@
> > 'Unexpected value of type_: %r' % type_)
> >
> > bus = self.raw_bus
> > - if self.device_id == UDEV_ROOT_PATH:
> > + if self.is_
> > # udev does not known about any product information for
> > # the root device. We use DMI data instead.
> > if type_ == 'vendor':
> >
> > === modified file
> 'lib/canonical/
> > --- lib/canonical/
> 2009-10-15 13:22:14 +0000
> > +++ lib/canonical/
> 2009-10-15 13:59:33 +0000
> > @@ -1173,6 +1173,51 @@
> > parser.
> > "Unknown bus 'nonsense' for device " + self.UDI_
> >
> > + def testHALDevice_
>
> A few tests above use the style:
>
> def test_HALDevice_
right, fixed.
> /dev.launchpad. net/TestsStyleG uide#Python Test Cases is_root_ device for the root device.""" submission_ key = 'Test of HALDevice. is_root_ device' buildDeviceList (parsed_ data) (parser. hal_devices[ self.UDI_ COMPUTER] .is_root_ device) is_root_ device_ for_non_ root_device( self): is_root_ device for a non-root device.""" PCCARD_ DEVICE, submission_ key = 'Test of HALDevice. is_root_ device' buildDeviceList (parsed_ data) hal_devices[ self.UDI_ PCCARD_ DEVICE] .is_root_ device) InfoSubsystem( self, devices): scsi_controller _data = { pccard_ bridge = { pci0000: 00/0000: 00:1e.0/ 0000:08: 03.0', scsi_controller _data = { pci0000: 00/0000: 00:1e.0/ 0000:08: 03.0/0000: 09:00.0' , bridge_ pccard_ hierarchy_ data = [ pccard_ bridge} , scsi_controller _data}, scsi_controller _scsi_side_ 2 = { pci0000: 00/0000: 00:1e.0/ 0000:08: 03.0/' 00.0/host6/ scsi_host/ host6') , device_ hierarchy_ data = [ scsi_controller _data}, scsi_controller _data},
> (I think from a previous review?). This seems more consistant with
>
> https:/
>
> > + """Test of HALDevice.
> > + devices = [
> > + {
> > + 'id': 1,
> > + 'udi': self.UDI_COMPUTER,
> > + 'properties': {},
> > + },
> > + ]
> > + parsed_data = {
> > + 'hardware': {
> > + 'hal': {
> > + 'devices': devices,
> > + },
> > + },
> > + }
> > +
> > + parser = SubmissionParser()
> > + parser.
> > + parser.
> > +
> self.assertTrue
> > +
> > + def testHALDevice_
> > + """Test of HALDevice.
> > + devices = [
> > + {
> > + 'id': 1,
> > + 'udi': self.UDI_
> > + 'properties': {},
> > + },
> > + ]
> > + parsed_data = {
> > + 'hardware': {
> > + 'hal': {
> > + 'devices': devices,
> > + },
> > + },
> > + }
> > +
> > + parser = SubmissionParser()
> > + parser.
> > + parser.
> > + self.assertFalse(
> > + parser.
> > +
> > def renameInfoBusTo
> > """Rename the property info.bus in a device list to info.subsystem.
> >
> > @@ -2837,7 +2882,19 @@
> > },
> > }
> >
> > - self.pci_
> > + self.pci_
> > + 'P': '/devices/
> > + 'E': {
> > + 'DRIVER': 'yenta_cardbus',
> > + 'PCI_CLASS': '60700',
> > + 'PCI_ID': '1217:7134',
> > + 'PCI_SUBSYS_ID': '10CF:131E',
> > + 'PCI_SLOT_NAME': '0000:08:03.0',
> > + 'SUBSYSTEM': 'pci',
> > + }
> > + }
> > +
> > + self.pccard_
> > 'P':
> '/devices/
> > 'E': {
> > 'DRIVER': 'aic7xxx',
> > @@ -2857,6 +2914,12 @@
> > },
> > }
> >
> > + self.pci_
> > + {'udev_data': self.root_device},
> > + {'udev_data': self.pci_
> > + {'udev_data': self.pccard_
> > + ]
> > +
> > self.pci_
> > 'P': ('/devices/
> > '0000:09:
> > @@ -2890,7 +2953,7 @@
> > }
> >
> > self.scsi_
> > - {'udev_data': self.pci_
> > + {'udev_data': self.pccard_
>
> Was this another problem with the test data? or something you updated
> for an updated test?
I changed the name because the device is indeed a PCCard, an I use it also in a new test of translatePciBus(), so I thought that the test data should get a more precise name.
Abel
@@ -1173,7 +1173,7 @@
parser. submission_ key,
" Unknown bus 'nonsense' for device " + self.UDI_ PCCARD_ DEVICE)
- def testHALDevice_ is_root_ device_ for_root_ device( self): is_root_ device_ for_root_ device( self): is_root_ device for the root device."""
parser. buildDeviceList (parsed_ data)
self. assertTrue( parser. hal_devices[ self.UDI_ COMPUTER] .is_root_ device)
+ def test_HALDevice_
"""Test of HALDevice.
devices = [
{
@@ -1195,7 +1195,7 @@
- def testHALDevice_ is_root_ device_ for_non_ root_device( self): is_root_ device_ for_non_ root_device( self): is_root_ device for a non-root device."""
+ def test_HALDevice_
"""Test of HALDevice.
devices = [
{