Code review comment for lp:~adeuring/launchpad/bug-438734-parse-kernel-release-nnode

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

This branch makes the method l.c.l.scripts.hwsdbsubmissions.SubmissionParser._parseSummary() aware of the new optional node <kernel-release> in HWDB submissions. Data submitted by the HWDB client in Karmic will contain this data.

test: ./bin/test-t test_hwdb_submission_parser

= 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_parser.py

== Pyflakes notices ==

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

lib/canonical/launchpad/scripts/tests/test_hwdb_submission_parser.py
    10: redefinition of unused 'etree' from line 8

== Pylint notices ==

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

This message is not related to my changes.

This branch is based on lp:~adeuring/launchpad/bug-438169-parse-sysfs-attr, reviewed by gmb, but not yet landed. The diff against this branch:

=== modified file 'lib/canonical/launchpad/scripts/hwdbsubmissions.py'
--- lib/canonical/launchpad/scripts/hwdbsubmissions.py 2009-09-29 10:11:50 +0000
+++ lib/canonical/launchpad/scripts/hwdbsubmissions.py 2009-09-29 15:02:47 +0000
@@ -260,6 +260,7 @@
         'contactable': _getValueAttributeAsBoolean,
         'date_created': _getValueAttributeAsDateTime,
         'client': _getClientData,
+ 'kernel-release': _getValueAttributeAsString,
         }

     def _parseSummary(self, summary_node):

=== modified file 'lib/canonical/launchpad/scripts/tests/test_hwdb_submission_parser.p
y'
--- lib/canonical/launchpad/scripts/tests/test_hwdb_submission_parser.py 2009-0
9-29 11:23:04 +0000
+++ lib/canonical/launchpad/scripts/tests/test_hwdb_submission_parser.py 2009-0
9-29 15:03:15 +0000
@@ -209,6 +209,58 @@
             summary, expected_data,
             'SubmissionParser.parseSummary returned an unexpected result')

+ def testSummaryNodeWithKernelRelease(self):
+ """The <smmary> node may contain the sub-node <kernel-release>."""
+ node = etree.fromstring("""
+ <summary>
+ <live_cd value="False"/>
+ <system_id value="f982bb1ab536469cebfd6eaadcea0ffc"/>
+ <distribution value="Ubuntu"/>
+ <distroseries value="7.04"/>
+ <architecture value="amd64"/>
+ <private value="False"/>
+ <contactable value="False"/>
+ <date_created value="2007-09-28T16:09:20.126842"/>
+ <client name="hwtest" version="0.9">
+ <plugin name="architecture_info" version="1.1"/>
+ <plugin name="find_network_controllers" version="2.34"/>
+ </client>
+ <kernel-release value="2.6.28-15-generic"/>
+ </summary>
+ """)
+ parser = SubmissionParser(self.log)
+ summary = parser._parseSummary(node)
+ utc_tz = pytz.timezone('UTC')
+ expected_data = {
+ 'live_cd': False,
+ 'system_id': 'f982bb1ab536469cebfd6eaadcea0ffc',
+ 'distribution': 'Ubuntu',
+ 'distroseries': '7.04',
+ 'architecture': 'amd64',
+ 'private': False,
+ 'contactable': False,
+ 'date_created': datetime(2007, 9, 28, 16, 9, 20, 126842,
+ tzinfo=utc_tz),
+ 'client': {
+ 'name': 'hwtest',
+ 'version': '0.9',
+ 'plugins': [
+ {
+ 'name': 'architecture_info',
+ 'version': '1.1'
+ },
+ {
+ 'name': 'find_network_controllers',
+ 'version': '2.34'
+ }
+ ]
+ },
+ 'kernel-release': '2.6.28-15-generic',
+ }
+ self.assertEqual(
+ summary, expected_data,
+ 'SubmissionParser.parseSummary returned an unexpected result')
+
     def _runPropertyTest(self, xml):
         parser = SubmissionParser(self.log)
         node = etree.fromstring(xml)

« Back to merge proposal