On 01.10.2009 10:15, Michael Nelson wrote:
> Review: Approve code
>> This branch is a first step to refactor class HALDevice in
>> l/c/l/scripts/hwdbsubmissions.py
>>
> ...
>
> r=me, just a few small copy-n-paste/ordering issues below.
>
> Thanks for the detailed description! Makes much more sense now :) It's
> nice seeing the preparation for the new UDevDevice in a separate small
> branch!
>
>
>> === modified file 'lib/canonical/launchpad/scripts/hwdbsubmissions.py'
>> --- lib/canonical/launchpad/scripts/hwdbsubmissions.py 2009-09-29 15:05:09 +0000
>> +++ lib/canonical/launchpad/scripts/hwdbsubmissions.py 2009-10-01 07:42:22 +0000
>> @@ -7,7 +7,7 @@
>> data and for the community test submissions.
>> """
>>
>> -
>> +__metaclass__ = type
>> __all__ = [
>> 'SubmissionParser',
>> 'process_pending_submissions',
>> @@ -1235,59 +1235,29 @@
>> root_device.createDBData(submission, None)
>> return True
>>
>> -class HALDevice:
>> - """The representation of a HAL device node."""
>> -
>> - def __init__(self, id, udi, properties, parser):
>> - """HALDevice constructor.
>> -
>> - :param id: The ID of the HAL device in the submission data as
>> - specified in <device id=...>.
>> - :type id: int
>> - :param udi: The UDI of the HAL device.
>> - :type udi: string
>> - :param properties: The HAL properties of the device.
>> - :type properties: dict
>> - :param parser: The parser processing a submission.
>> - :type parser: SubmissionParser
>> - """
>> - self.id = id
>> - self.udi = udi
>> - self.properties = properties
>> +
>> +class BaseDevice:
>> + """A base class to represent device data from HAL and udev."""
>
> There should be a blank line here? (like all the other classes in this file).
Fixed.
>
>> === modified file 'lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py'
>> --- lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py 2009-06-25 05:30:52 +0000
>> +++ lib/canonical/launchpad/scripts/tests/test_hwdb_submission_processing.py 2009-10-01 07:42:22 +0000
>> @@ -380,6 +380,51 @@
>> 'Unexpected value of HALDevice.parent_udi, '
>> 'when no parent information available.')
>>
>> + def testHALDeviceDeviceId(self):
>
> I'm guessing you're aware that these should be pep8-style names,
>
> https://dev.launchpad.net/TestsStyleGuide#Python Test Cases
>
> but in this case the rest of the file uses camel-case, so for consistency...
>
>> + """Test of HALDevice.device_id."""
>> + properties = {}
>> + parser = SubmissionParser(self.log)
>> + device = HALDevice(1, '/some/udi/path', properties, parser)
>> + self.assertEqual(
>> + '/some/udi/path', device.device_id,
>> + 'Unexpected value of HALDevice.parent_udi')
>
> Should this be 'Unexpected value of HALDevice.device_id (which actually
> returns self.udi not parent_udi?)
oops, sure. Fixed.
>
>> +
>> + def testHALDevicePciClass(self):
>> + """Test of HALDevice.pci_class."""
>> + properties = {
>> + 'pci.device_class': (1, 'int'),
>> + }
>> + parser = SubmissionParser(self.log)
>> + device = HALDevice(1, '/some/udi/path', properties, parser)
>> + self.assertEqual(
>> + device.pci_class, 1,
>
> Hardly worth mentioning, but the expected value should be first like
> your previous test above.
Right. There are two challenges for me: Personally, I prefer the order
exiting value, expected value ordering, and most of the existing tests
use this order... Fixed.
>
>> + 'Unexpected value of HALDevice.device_class.')
>
> Again, HALDevice.pci_class?
Hi Michael,
thanks for the review!
On 01.10.2009 10:15, Michael Nelson wrote: hwdbsubmissions .py paste/ordering issues below. launchpad/ scripts/ hwdbsubmissions .py' launchpad/ scripts/ hwdbsubmissions .py 2009-09-29 15:05:09 +0000 launchpad/ scripts/ hwdbsubmissions .py 2009-10-01 07:42:22 +0000 pending_ submissions' , createDBData( submission, None)
> Review: Approve code
>> This branch is a first step to refactor class HALDevice in
>> l/c/l/scripts/
>>
> ...
>
> r=me, just a few small copy-n-
>
> Thanks for the detailed description! Makes much more sense now :) It's
> nice seeing the preparation for the new UDevDevice in a separate small
> branch!
>
>
>> === modified file 'lib/canonical/
>> --- lib/canonical/
>> +++ lib/canonical/
>> @@ -7,7 +7,7 @@
>> data and for the community test submissions.
>> """
>>
>> -
>> +__metaclass__ = type
>> __all__ = [
>> 'SubmissionParser',
>> 'process_
>> @@ -1235,59 +1235,29 @@
>> root_device.
>> return True
>>
>> -class HALDevice:
>> - """The representation of a HAL device node."""
>> -
>> - def __init__(self, id, udi, properties, parser):
>> - """HALDevice constructor.
>> -
>> - :param id: The ID of the HAL device in the submission data as
>> - specified in <device id=...>.
>> - :type id: int
>> - :param udi: The UDI of the HAL device.
>> - :type udi: string
>> - :param properties: The HAL properties of the device.
>> - :type properties: dict
>> - :param parser: The parser processing a submission.
>> - :type parser: SubmissionParser
>> - """
>> - self.id = id
>> - self.udi = udi
>> - self.properties = properties
>> +
>> +class BaseDevice:
>> + """A base class to represent device data from HAL and udev."""
>
> There should be a blank line here? (like all the other classes in this file).
Fixed.
> launchpad/ scripts/ tests/test_ hwdb_submission _processing. py' launchpad/ scripts/ tests/test_ hwdb_submission _processing. py 2009-06-25 05:30:52 +0000 launchpad/ scripts/ tests/test_ hwdb_submission _processing. py 2009-10-01 07:42:22 +0000 parent_ udi, ' viceId( self): /dev.launchpad. net/TestsStyleG uide#Python Test Cases device_ id.""" r(self. log) parent_ udi')
>> === modified file 'lib/canonical/
>> --- lib/canonical/
>> +++ lib/canonical/
>> @@ -380,6 +380,51 @@
>> 'Unexpected value of HALDevice.
>> 'when no parent information available.')
>>
>> + def testHALDeviceDe
>
> I'm guessing you're aware that these should be pep8-style names,
>
> https:/
>
> but in this case the rest of the file uses camel-case, so for consistency...
>
>> + """Test of HALDevice.
>> + properties = {}
>> + parser = SubmissionParse
>> + device = HALDevice(1, '/some/udi/path', properties, parser)
>> + self.assertEqual(
>> + '/some/udi/path', device.device_id,
>> + 'Unexpected value of HALDevice.
>
> Should this be 'Unexpected value of HALDevice.device_id (which actually
> returns self.udi not parent_udi?)
oops, sure. Fixed.
> iClass( self): pci_class. """ r(self. log)
>> +
>> + def testHALDevicePc
>> + """Test of HALDevice.
>> + properties = {
>> + 'pci.device_class': (1, 'int'),
>> + }
>> + parser = SubmissionParse
>> + device = HALDevice(1, '/some/udi/path', properties, parser)
>> + self.assertEqual(
>> + device.pci_class, 1,
>
> Hardly worth mentioning, but the expected value should be first like
> your previous test above.
Right. There are two challenges for me: Personally, I prefer the order
exiting value, expected value ordering, and most of the existing tests
use this order... Fixed.
> device_ class.' ) pci_class?
>> + 'Unexpected value of HALDevice.
>
> Again, HALDevice.
fixed.
> r(self. log)
>> +
>> + properties = {}
>> + parser = SubmissionParse
>> + device = HALDevice(1, '/some/udi/path', properties, parser)
>> + self.assertEqual(
>> + device.pci_class, None,
>
> ordering...
Fixed.
> device_ class for Non-PCI device.')
>> + 'Unexpected value of HALDevice.
>
> and pic_class?
Fixed.
> iSubClass( self): pci_subclass. """ subclass' : (1, 'int'), r(self. log) pci_subclass, 1,
>> +
>> + def testHALDevicePc
>> + """Test of HALDevice.
>> + properties = {
>> + 'pci.device_
>> + }
>> + parser = SubmissionParse
>> + device = HALDevice(1, '/some/udi/path', properties, parser)
>> + self.assertEqual(
>> + device.
>
> ordering...
Fixed.
> device_ class.' )
>> + 'Unexpected value of HALDevice.
>
> and pci_subclass?
Fixed.
> r(self. log) pci_subclass, None,
>> +
>> + properties = {}
>> + parser = SubmissionParse
>> + device = HALDevice(1, '/some/udi/path', properties, parser)
>> + self.assertEqual(
>> + device.
>
> ordering...
Fixed.
> device_ class for Non-PCI device.')
>> + 'Unexpected value of HALDevice.
>
> and pci_subclass?
Fixed.
Abel
> wBus(self) : raw_bus. """
>> +
>> def testHalDeviceRa
>> """test of HALDevice.
>> properties = {
>
> Great! All trivialities :)
>
> Thanks Abel.