l.h.s.t.t.TestHWDBSubmissionParser(TestCase) : class documentation

Part of lp.hardwaredb.scripts.tests.test_hwdb_submission_parser View In Hierarchy

Tests of the HWDB submission parser.
Method setUp Setup the test environment.
Method getTimestampETreeNode Return an Elementtree node for an XML tag with a timestamp.
Method testTimeConversion Test of the conversion of a "time string" into datetime object.
Method testSummary Undocumented
Method testSummaryNodeWithKernelRelease The <summary> node may contain the sub-node <kernel-release>.
Method testBooleanPropertyTypes Test the parsing result for a boolean property.
Method testStringPropertyTypes String properties are converted into (name, (value, type)).
Method testStringPropertyEncoding Different encodings are properly handled.
Method testIntegerPropertyTypes Int properties are converted into (name, (value, type_string)).
Method testFloatPropertyTypes Float properties are converted into ('name', (value, type_string)).
Method testListPropertyTypes List properties are converted into ('name', a_list).
Method testDictPropertyTypes Dict properties are converted into ('name', a_dict).
Method testProperties A set of properties is converted into a dictionary.
Method testDevice A device node is converted into a dictionary.
Method testHal The <hal> node is converted into a Python dict.
Method testProcessors The <processors> node is converted into a Python list.
Method testAliases The <aliases> node is converted into a Python list.
Method testUdev The content of the <udev> node is converted into a list of dicts.
Method testUdevLineWithoutColon <udev> nodes with lines not in key: value format are rejected.
Method testUdevPropertyLineWithoutEqualSign <udev> nodes with lines not in key: value format are rejected.
Method testUdevDataWithDuplicateKey <udev> nodes with lines not in key: value format are rejected.
Method testDmi The content of the <udev> node is converted into a dictionary.
Method testDmiInvalidData <dmi> nodes with lines not in key:value format are rejected.
Method testSysfsAttributes Test of SubmissionParser._parseSysfsAttributes().
Method testSysfsAttributesLineWithoutKeyValueData Test of SubmissionParser._parseSysfsAttributes().
Method testSysfsAttributesDuplicatePLine Test of SubmissionParser._parseSysfsAttributes().
Method testSysfsAttributesNoPLineAtDeviceStart Test of SubmissionParser._parseSysfsAttributes().
Method testSysfsAttributesNoAttributeKeyValue Test of SubmissionParser._parseSysfsAttributes().
Method testSysfsAttributesInvalidMainKey Test of SubmissionParser._parseSysfsAttributes().
Class MockSubmissionParserParseHardwareTest A SubmissionParser variant for testing checkCOnsistentData()
Method testHardware The <hardware> tag is converted into a dictionary.
Method testHardware_no_sysfs_node If teh <sysfs-attributes> node is missing, parseHardware()
Method test_parseHardware_sub_parsers_fail Test of SubmissionParser._parseHardware().
Method testLsbRelease The <lsbrelease> node is converted into a Python dictionary.
Method testPackages The <packages> node is converted into a Python dictionary.
Method testDuplicatePackage Two <package> nodes with the same name are rejected.
Method testXorg The <xorg> node is converted into a Python dictionary.
Method testDuplicateXorgDriver Two <driver> nodes in <xorg> with the same name are rejected.
Method test_parseSoftware Test SubmissionParser._parseSoftware
Method test_parseSoftware_without_xorg_node Test SubmissionParser._parseSoftware
Method test_parseSoftware_without_packages_node Test SubmissionParser._parseSoftware
Method testMultipleChoiceQuestion The <questions> node is converted into a Python dictionary.
Method testMeasurementQuestion The <questions> node is converted into a Python dictionary.
Method testContext The content of the <context> node is currently not processed.
Class MockSubmissionParserMainParserTest A SubmissionParser variant for testing checkCOnsistentData()
Method testMainParser Test SubmissionParser.parseMainSections
Method testSubmissionParser Test the entire parser.
Method testFindDuplicates Test of SubmissionParser._findDuplicates.
Method testFindDuplicateIDs SubmissionParser.findDuplicateIDs lists duplicate IDS.
Method testFindDuplicateIDsUdev SubmissionParser.findDuplicateIDs lists duplicate IDS.
Method testFindDuplicateIDsDuplicateUdevNode SubmissionParser.findDuplicateIDs lists duplicate IDS.
Method testIDMap Test of SubmissionParser._getIDMap.
Method testIDMapUdev Test of SubmissionParser._getIDMap.
Method testInvalidIDReferencesUdev Test of SubmissionParser.checkIDReferences.
Method testUDIDeviceMap Test the creation of the mapping UDI -> device.
Method testIDUDIMaps Test of SubmissionParser._getIDUDIMaps.
Method testUDIChildren Test of SubmissionParser.getUDIChildren.
Method testUDIDeviceMapInvalidRootNode The root node of the devices must have a special UDI.
Method testUDIDeviceMapMissingRootNode If no root node exists, getUDIChildren raises a ValueError.
Method testParentChildInconsistency Test of SubmissionParser.checkHALDevicesParentChildConsistency.
Method testCheckUdevDictsHavePathKey Test of SubmissionParser.checkNodesHavePathKey()
Method testCheckUdevPciProperties Test of SubmissionParser.checkUdevPciProperties().
Method testCheckUdevPciPropertiesNonPciDeviceWithPciProperties Test of SubmissionParser.checkUdevPciProperties().
Method testCheckUdevPciPropertiesPciDeviceWithoutRequiredProperties Test of SubmissionParser.checkUdevPciProperties().
Method testCheckUdevPciPropertiesPciDeviceWithNonIntegerPciClass Test of SubmissionParser.checkUdevPciProperties().
Method testCheckUdevPciPropertiesPciDeviceWithInvalidPciClassValue Test of SubmissionParser.checkUdevPciProperties().
Method testCheckUdevPciPropertiesPciDeviceWithInvalidDeviceID Test of SubmissionParser.checkUdevPciProperties().
Method testCheckUdevPciPropertiesPciDeviceWithInvalidSubsystemID Test of SubmissionParser.checkUdevPciProperties().
Method testCheckUdevUsbProperties Test of SubmissionParser.checkUdevUsbProperties().
Method testCheckUdevUsbProperties_missing_required_property Test of SubmissionParser.checkUdevUsbProperties().
Method testCheckUdevUsbProperties_with_invalid_product_id Test of SubmissionParser.checkUdevUsbProperties().
Method testCheckUdevUsbProperties_with_invalid_type_data Test of SubmmissionParser.checkUdevUsbProperties().
Method testCheckUdevUsbProperties_with_invalid_devtype Test of SubmmissionParser.checkUdevUsbProperties().
Method testCheckUdevUsbProperties_interface_without_interface_property Test of SubmmissionParser.checkUdevUsbProperties().
Method testCheckUdevUsbProperties_interface_invalid_interface_property Test of SubmmissionParser.checkUdevUsbProperties().
Method testCheckUdevScsiProperties Test of SubmissionParser.checkUdevScsiProperties().
Method testCheckUdevScsiProperties_data_is_none Test of SubmissionParser.checkUdevScsiProperties().
Method testCheckUdevScsiProperties_missing_devtype Test of SubmissionParser.checkUdevScsiProperties().
Method testCheckUdevScsiProperties_no_sysfs_data Test of SubmissionParser.checkUdevScsiProperties().
Method testCheckUdevScsiProperties_missing_sysfs_attributes Test of SubmissionParser.checkUdevScsiProperties().
Class UdevTestSubmissionParser A variant of SubmissionParser that shortcuts udev related tests.
Method testCheckConsistentUdevDeviceData Test of SubmissionParser.checkConsistentUdevDeviceData(),
Method testCheckConsistentUdevDeviceData_invalid_path_data Test of SubmissionParser.checkConsistentUdevDeviceData(),
Method testCheckConsistentUdevDeviceData_invalid_pci_data Test of SubmissionParser.checkConsistentUdevDeviceData(),
Method testCheckConsistentUdevDeviceData_invalid_usb_data Test of SubmissionParser.checkConsistentUdevDeviceData(),
Method testCheckConsistentUdevDeviceData_invalid_scsi_data Test of SubmissionParser.checkConsistentUdevDeviceData(),
Method testCheckConsistentUdevDeviceData_invalid_dmi_data Test of SubmissionParser.checkConsistentUdevDeviceData(),
Class MockSubmissionParser A SubmissionParser variant for testing checkCOnsistentData()
Method assertErrorMessage Search for message in the log entries for submission_key.
Method assertWarningMessage Search for message in the log entries for submission_key.
Method testConsistencyCheck Test of SubmissionParser.checkConsistency.
Method testConsistencyCheckValidUdevData Test of SubmissionParser.checkConsistency.
Method testConsistencyCheck_invalid_udev_data Test of SubmissionParser.checkConsistency.
Method testConsistencyCheckWithDuplicateIDs SubmissionParser.checkConsistency detects duplicate IDs.
Method testConsistencyCheckWithInvalidIDReferences SubmissionParser.checkConsistency detects invalid ID references.
Method testConsistencyCheckWithDuplicateUDI SubmissionParser.checkConsistency detects duplicate UDIs.
Method testConsistencyCheckChildUDIWithoutParent SubmissionParser.checkConsistency detects "orphaned" devices.
Method testConsistencyCheckCircularParentChildRelation SubmissionParser.checkConsistency detects "orphaned" devices.
Method _runPropertyTest Undocumented

Inherited from TestCase:

Method becomeDbUser Commit, then log into the database as dbuser.
Method __str__ The string representation of a test is its id.
Method useContext Use the supplied context in this test.
Method makeTemporaryDirectory Create a temporary directory, and return its path.
Method installKarmaRecorder Set up and return a KarmaRecorder.
Method assertProvides Assert 'obj' correctly provides 'interface'.
Method assertNotifies Assert that a callable performs a given notification.
Method assertNoNotification Assert that no notifications are generated by the callable.
Method assertSqlAttributeEqualsDate Fail unless the value of the attribute is equal to the date.
Method assertTextMatchesExpressionIgnoreWhitespace Undocumented
Method assertIsInstance Assert that an instance is an instance of assert_class.
Method assertIsNot Assert that expected is not the same object as observed.
Method assertContentEqual Assert that 'iter1' has the same content as 'iter2'.
Method assertRaisesWithContent Check if the given exception is raised with given content.
Method assertBetween Assert that 'variable' is strictly between two boundaries.
Method assertVectorEqual Apply assertEqual to all given pairs in one go.
Method expectedLog Expect a log to be written that matches the regex.
Method pushConfig Push some key-value pairs into a section of the config.
Method attachOopses Undocumented
Method attachLibrarianLog Include the logChunks from fixture in the test details.
Method assertStatementCount Assert that the expected number of SQL statements occurred.
Method useTempDir Use a temporary directory for this test.
Method assertEmailHeadersEqual Assert that two email headers are equal.
Method assertStartsWith Undocumented
Method assertEndsWith Asserts that s ends with suffix.
Method checkPermissions Check if the used_permissions match expected_permissions.
Method assertEmailQueueLength Pop the email queue, assert its length, and return it.
Method _unfoldEmailHeader Unfold a multiline email header.
def setUp(self):
Setup the test environment.
def getTimestampETreeNode(self, time_string):
Return an Elementtree node for an XML tag with a timestamp.
def testTimeConversion(self):
Test of the conversion of a "time string" into datetime object.
def testSummary(self):
Undocumented
def testSummaryNodeWithKernelRelease(self):
The <summary> node may contain the sub-node <kernel-release>.
def _runPropertyTest(self, xml):
Undocumented
def testBooleanPropertyTypes(self):
Test the parsing result for a boolean property.
def testStringPropertyTypes(self):
String properties are converted into (name, (value, type)).
def testStringPropertyEncoding(self):
Different encodings are properly handled.
def testIntegerPropertyTypes(self):
Int properties are converted into (name, (value, type_string)).

type(value) is int or long, depending on the value.

def testFloatPropertyTypes(self):
Float properties are converted into ('name', (value, type_string)).

type(value) is float.

def testListPropertyTypes(self):
List properties are converted into ('name', a_list).

a_list is a Python list, where the list elements represent the values of the <value> sub-nodes of the <property>.

def testDictPropertyTypes(self):
Dict properties are converted into ('name', a_dict).

a_dict is a Python dictionary, where the items represent the values of the <value> sub-nodes of the <property>.

def testProperties(self):
A set of properties is converted into a dictionary.
def testDevice(self):
A device node is converted into a dictionary.
def testHal(self):
The <hal> node is converted into a Python dict.
def testProcessors(self):
The <processors> node is converted into a Python list.

The list elements represent the <processor> nodes.

def testAliases(self):
The <aliases> node is converted into a Python list.

The list elements represent the <alias> nodes.

def testUdev(self):
The content of the <udev> node is converted into a list of dicts.
def testUdevLineWithoutColon(self):
<udev> nodes with lines not in key: value format are rejected.
def testUdevPropertyLineWithoutEqualSign(self):
<udev> nodes with lines not in key: value format are rejected.
def testUdevDataWithDuplicateKey(self):
<udev> nodes with lines not in key: value format are rejected.
def testDmi(self):
The content of the <udev> node is converted into a dictionary.
def testDmiInvalidData(self):
<dmi> nodes with lines not in key:value format are rejected.
def testSysfsAttributes(self):
Test of SubmissionParser._parseSysfsAttributes().

The content of the <sys-attributes> node is converted into a dictionary.

def testSysfsAttributesLineWithoutKeyValueData(self):
Test of SubmissionParser._parseSysfsAttributes().

Lines not in key: value format are rejected.

def testSysfsAttributesDuplicatePLine(self):
Test of SubmissionParser._parseSysfsAttributes().

A line starting with "P:" must be the first line of a device block.

def testSysfsAttributesNoPLineAtDeviceStart(self):
Test of SubmissionParser._parseSysfsAttributes().

The data for a device must start with a "P:" line.

def testSysfsAttributesNoAttributeKeyValue(self):
Test of SubmissionParser._parseSysfsAttributes().

A line starting with "A:" must be in key=value format.

def testSysfsAttributesInvalidMainKey(self):
Test of SubmissionParser._parseSysfsAttributes().

All lines must start with "P:" or "A:".

def testHardware(self):
The <hardware> tag is converted into a dictionary.
def testHardware_no_sysfs_node(self):
If teh <sysfs-attributes> node is missing, parseHardware() returns a dicitionary where the entry for this node is None.
def test_parseHardware_sub_parsers_fail(self):
Test of SubmissionParser._parseHardware().

If one of the sub-parsers returns None, _parseHardware() returns None.

def testLsbRelease(self):
The <lsbrelease> node is converted into a Python dictionary.

Each dict item represents a <property> sub-node.

def testPackages(self):
The <packages> node is converted into a Python dictionary.

Each dict item represents a <package> sub-node as (package_name, package_data), where package_data is a dictionary representing the <property> sub-nodes of a <package> node.

def testDuplicatePackage(self):
Two <package> nodes with the same name are rejected.
def testXorg(self):
The <xorg> node is converted into a Python dictionary.
def testDuplicateXorgDriver(self):
Two <driver> nodes in <xorg> with the same name are rejected.
def test_parseSoftware(self):
Test SubmissionParser._parseSoftware

Ensure that all sub-parsers are properly called.

def test_parseSoftware_without_xorg_node(self):
Test SubmissionParser._parseSoftware

Ensure that _parseSoftware creates an entry in its result for <xorg> even if the submitted data does not contains this node.

def test_parseSoftware_without_packages_node(self):
Test SubmissionParser._parseSoftware

Ensure that _parseSoftware creates an entry in its result for <packages> even if the submitted data does not contains this node.

def testMultipleChoiceQuestion(self):
The <questions> node is converted into a Python dictionary.
def testMeasurementQuestion(self):
The <questions> node is converted into a Python dictionary.
def testContext(self):
The content of the <context> node is currently not processed.

Instead, a log warning is issued.

def testMainParser(self):
Test SubmissionParser.parseMainSections

Ensure that all sub-parsers are properly called.

def testSubmissionParser(self):
Test the entire parser.
def testFindDuplicates(self):
Test of SubmissionParser._findDuplicates.
def testFindDuplicateIDs(self):
SubmissionParser.findDuplicateIDs lists duplicate IDS.

The IDs of HAL devices, processors and packages should be unique.

def testFindDuplicateIDsUdev(self):
SubmissionParser.findDuplicateIDs lists duplicate IDS.

The IDs of udev devices, processors and packages should be unique.

def testFindDuplicateIDsDuplicateUdevNode(self):
SubmissionParser.findDuplicateIDs lists duplicate IDS.

Two udev dictionaries with the same device['P'] value are invalid.

def testIDMap(self):
Test of SubmissionParser._getIDMap.
def testIDMapUdev(self):
Test of SubmissionParser._getIDMap.

Variant for submissions with udev data.

def testInvalidIDReferencesUdev(self):
Test of SubmissionParser.checkIDReferences.

Variant for submissions containing udev data.

def testUDIDeviceMap(self):
Test the creation of the mapping UDI -> device.
def testIDUDIMaps(self):
Test of SubmissionParser._getIDUDIMaps.
def testUDIChildren(self):
Test of SubmissionParser.getUDIChildren.
def testUDIDeviceMapInvalidRootNode(self):
The root node of the devices must have a special UDI.

getUDIChildren ensures that the only device without an info.parent property has the UDI /org/freedesktop/Hal/devices/computer (ROOT_UDI).

def testUDIDeviceMapMissingRootNode(self):
If no root node exists, getUDIChildren raises a ValueError.
def testParentChildInconsistency(self):
Test of SubmissionParser.checkHALDevicesParentChildConsistency.
def testCheckUdevDictsHavePathKey(self):
Test of SubmissionParser.checkNodesHavePathKey()
def testCheckUdevPciProperties(self):
Test of SubmissionParser.checkUdevPciProperties().
def testCheckUdevPciPropertiesNonPciDeviceWithPciProperties(self):
Test of SubmissionParser.checkUdevPciProperties().

A non-PCI device having PCI properties makes a submission invalid.

def testCheckUdevPciPropertiesPciDeviceWithoutRequiredProperties(self):
Test of SubmissionParser.checkUdevPciProperties().

A PCI device not having a required PCI property makes a submission invalid.

def testCheckUdevPciPropertiesPciDeviceWithNonIntegerPciClass(self):
Test of SubmissionParser.checkUdevPciProperties().

A PCI device with a non-integer class value makes a submission invalid.

def testCheckUdevPciPropertiesPciDeviceWithInvalidPciClassValue(self):
Test of SubmissionParser.checkUdevPciProperties().

A PCI device with invalid class data makes a submission invalid.

def testCheckUdevPciPropertiesPciDeviceWithInvalidDeviceID(self):
Test of SubmissionParser.checkUdevPciProperties().

A PCI device with an invalid device ID makes a submission invalid.

def testCheckUdevPciPropertiesPciDeviceWithInvalidSubsystemID(self):
Test of SubmissionParser.checkUdevPciProperties().

A PCI device with an invalid subsystem ID makes a submission invalid.

def testCheckUdevUsbProperties(self):
Test of SubmissionParser.checkUdevUsbProperties().

udev nodes for USB devices must define the three properties DEVTYPE, PRODUCT, TYPE or none of them.

def testCheckUdevUsbProperties_missing_required_property(self):
Test of SubmissionParser.checkUdevUsbProperties().

A USB device where some but not all of the properties DEVTYPE, PRODUCT, TYPE are defined makes a submission invalid.

def testCheckUdevUsbProperties_with_invalid_product_id(self):
Test of SubmissionParser.checkUdevUsbProperties().

A USB device with an invalid product ID makes a submission invalid.

def testCheckUdevUsbProperties_with_invalid_type_data(self):
Test of SubmmissionParser.checkUdevUsbProperties().

A USB device with invalid type data makes a submission invalid.

def testCheckUdevUsbProperties_with_invalid_devtype(self):
Test of SubmmissionParser.checkUdevUsbProperties().

A udev USB device must have DEVTYPE set to 'usb_device' or 'usb_interface'.

def testCheckUdevUsbProperties_interface_without_interface_property(self):
Test of SubmmissionParser.checkUdevUsbProperties().

A udev USB device for a USB interface have the property INTERFACE.

def testCheckUdevUsbProperties_interface_invalid_interface_property(self):
Test of SubmmissionParser.checkUdevUsbProperties().

The INTERFACE proeprty of A udev USB device for a USB interface must have value in the format main_class/sub_class/version

def testCheckUdevScsiProperties(self):
Test of SubmissionParser.checkUdevScsiProperties().
def testCheckUdevScsiProperties_data_is_none(self):
Test of SubmissionParser.checkUdevScsiProperties().

checkUdevScsiProperties() even if no sysfs properties are available.

def testCheckUdevScsiProperties_missing_devtype(self):
Test of SubmissionParser.checkUdevScsiProperties().

Each udev SCSI node must define the DEVTYPE property.

def testCheckUdevScsiProperties_no_sysfs_data(self):
Test of SubmissionParser.checkUdevScsiProperties().

Each udev SCSI node must have a corresponding sysfs node.

def testCheckUdevScsiProperties_missing_sysfs_attributes(self):
Test of SubmissionParser.checkUdevScsiProperties().

Each sysfs node for a udev SCSI node must have a the attribues vendor, model and type.

def testCheckConsistentUdevDeviceData(self):
Test of SubmissionParser.checkConsistentUdevDeviceData(),
def testCheckConsistentUdevDeviceData_invalid_path_data(self):
Test of SubmissionParser.checkConsistentUdevDeviceData(),

Detection of invalid path data lets the check fail.

def testCheckConsistentUdevDeviceData_invalid_pci_data(self):
Test of SubmissionParser.checkConsistentUdevDeviceData(),

Detection of invalid PCI data lets the check fail.

def testCheckConsistentUdevDeviceData_invalid_usb_data(self):
Test of SubmissionParser.checkConsistentUdevDeviceData(),

Detection of invalid USB data lets the check fail.

def testCheckConsistentUdevDeviceData_invalid_scsi_data(self):
Test of SubmissionParser.checkConsistentUdevDeviceData(),

Detection of invalid SCSI data lets the check fail.

def testCheckConsistentUdevDeviceData_invalid_dmi_data(self):
Test of SubmissionParser.checkConsistentUdevDeviceData(),

Detection of invalid DMI data lets the check fail.

def assertErrorMessage(self, submission_key, log_message):
Search for message in the log entries for submission_key.

assertErrorMessage requires that
(a) a log message starts with "Parsing submisson <submission_key>:"
(b) the error message passed as the parameter message appears
    in a log string that matches (a)
(c) result, which is supposed to contain an object representing
    the result of parsing a submission, is None.
(d) the log level is ERROR.

If all four criteria match, assertErrormessage does not raise any
exception.
def assertWarningMessage(self, submission_key, log_message):
Search for message in the log entries for submission_key.

assertErrorMessage requires that
(a) a log message starts with "Parsing submisson <submission_key>:"
(b) the error message passed as the parameter message appears
    in a log string that matches (a)
(c) result, which is supposed to contain an object representing
    the result of parsing a submission, is None.
(d) the log level is WARNING.

If all four criteria match, assertWarningMessage does not raise any
exception.
def testConsistencyCheck(self):
Test of SubmissionParser.checkConsistency.
def testConsistencyCheckValidUdevData(self):
Test of SubmissionParser.checkConsistency.
def testConsistencyCheck_invalid_udev_data(self):
Test of SubmissionParser.checkConsistency.
def testConsistencyCheckWithDuplicateIDs(self):
SubmissionParser.checkConsistency detects duplicate IDs.
def testConsistencyCheckWithInvalidIDReferences(self):
SubmissionParser.checkConsistency detects invalid ID references.
def testConsistencyCheckWithDuplicateUDI(self):
SubmissionParser.checkConsistency detects duplicate UDIs.
def testConsistencyCheckChildUDIWithoutParent(self):
SubmissionParser.checkConsistency detects "orphaned" devices.
def testConsistencyCheckCircularParentChildRelation(self):
SubmissionParser.checkConsistency detects "orphaned" devices.
API Documentation for Launchpad, generated by pydoctor at 2018-05-24 00:00:11.