Code review comment for lp:~adeuring/launchpad/hwdb-class-udev-device-6

Revision history for this message
Abel Deuring (adeuring) wrote :

This branch adds a property scsi_controller to class UdevDevice in the script hwdbsubmissons.py.

Aside from tests of this property, I also added tests for UdevDevice.translateScsiBus(). While this method is defined in class BaseDevice, from which UdevDevice is derived, is accesses the property scsi_controller, so some tests seemed reasonable. (class UdevDevice represents a device mentioned in a submission made by Karmic's HWDB client, while submissions from older Ubuntu versions contain data from HAL; these devices are represnted by class HALDevice.)

Handling of SCSI devices in HWDB submissions is a bit convoluted: Many non-SCSI storage devices, like IDE/SATA disks and CD drives and USB storage devices, support the SCSI command set, and the Linux kernel treats them like real SCSI devices. The data stored about a device includes the bus used to connect the device to a computer, so we want to know the real, physical bus of a device, instead of treating nearly all storage devices as SCSI devices.

We can detect the real bus a of (real or fake) SCSI device by inspecting the type of the (real or fake) SCSI controller. This is done by BaseDevice.translateScsiBus(). The core logic of this method is the same for submissions containing HAL and udev data, so it is located in class BaseDevice. The difference between HAL and udev data is that the controller of a SCSI device in HAL is the grandparent of the SCSI device, while it is the grand-grand-grand-parent in udev, hence the property scsi_controller is differently implemented in HALDevice and UdevDevice.

In order to setup a test of UdevDevice.scsi_controller or UdevDevice.translateScsiBus, we need to create five UdevDevices, so I added a method buildUdevDeviceHierarchy() to class TestUdevDevice.

I also changed the base class of TestUdevDevice from TestCase to testCaseHWDB: The latter defines some infrastructure to assert that expected warnings or error messages really appear.

test: ./bin/test --test=test_hwdb_submission_processing

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/canonical/launchpad/scripts/hwdbsubmissions.py
  lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py

== Pyflakes notices ==

lib/canonical/launchpad/scripts/hwdbsubmissions.py
    22: redefinition of unused 'etree' from line 20

== Pylint notices ==

lib/canonical/launchpad/scripts/hwdbsubmissions.py
    20: [F0401] Unable to import 'xml.etree.cElementTree' (No module named etree)

This complaint is not related to my changes.

« Back to merge proposal