l.h.t.t.TestHWDBSubmissionRelaxNGValidation(TestCase) : class documentation

Part of lp.hardwaredb.tests.test_hwdb_submission_validation View In Hierarchy

Tests of the Relax NG validation of the HWDB submission parser.
Method setUp Setup the test environment.
Method runValidator Run the Relax NG validator.
Method insertSampledata Insert text into the sample data data.
Method replaceSampledata Replace text in the sample data data.
Method testNoXMLData The raw submission data must be XML.
Method testInvalidRootNode The root node must be <system>.
Method testBadDataInCommentNode Many submissions contain ESC symbols in <comment> nodes.
Method test_fixFrequentErrors_two_comments Undocumented
Method test_bad_data_does_not_oops Undocumented
Method testInvalidFormatVersion The attribute format of the root node must be 1.0.
Method testMissingFormatVersion The root node must have the attribute version.
Method testAsciiEncoding Validation of ASCII encoded XML data.
Method testISO8859_1_Encoding XML data with ISO-8859-1 may have bytes with bit 7 set.
Method testUTF8Encoding UTF-8 encoded data is properly detected and parsed.
Method assertErrorMessage Search for message in the log entries for submission_key.
Method testAssertErrorMessage Test the assertErrorMessage method.
Method testSubtagsOfSystem The root node <system> requires a fixed set of sub-tags.
Method testSummaryRequiredTags The <summary> section requires a fixed set of sub-tags.
Method testAdditionalSummaryTags Arbitrary tags are forbidden as sub-tags of <summary>.
Method testSummaryValidationOfBooleanSubtags Validation of boolean tags in the <summary> section.
Method testDateCreatedParsing Parsing of the date_created value.
Method assertDateErrorIsDetected Run a single test for an invalid datetime.
Method assertValidDateTime Run a single test for a valid datetime.
Method testClientTagAttributes Validation of <client> tag attributes.
Method testSubTagsOfClient The only allowed sub-tag of <client> is <plugin>.
Method testClientPluginAttributes Validation of <plugin> tag attributes.
Method testHardwareSubTagHalOrUdev The <hardware> tag requires data about hardware devices.
Method testHardwareSubTagUdevIncomplete The <hardware> tag has a fixed set of allowed sub-tags.
Method testHardwareSubTagHalMixedWithUdev Mixing <hal> with <udev>, <dmi>, <sysfs-attributes> is impossible.
Method testHardwareOtherSubTags The <hardware> tag has a fixed set of allowed sub-tags.
Method testHalAttributes Validation of <hal> tag attributes.
Method testHalSubtags Validation of sub-tags of <hal>.
Method testDeviceAttributes Validation of the attributes of the <device> tag.
Method testDeviceContent <device> tags may only contain <property> tags.
Method testBooleanProperties Undocumented
Method testStringProperties Validation of string properties.
Method testIntegerProperties Validation of integer properties.
Method testDecimalProperties Validation of dbus.Double and float properties.
Method assertAcceptsEmptyProperty Validation of empty list properties.
Method assertRejectsNonValueSubtag Other sub-tags than <value> are not allowed in lists and dicts.
Method assertValidatesTextValue Validation of tags with CData values
Method testListAndDictProperties Validation of dbus.Array and list properties.
Method testProcessorsTag Validation of the <processors> tag.
Method testProcessorTag Validation of the <processors> tag.
Method testAliasesTag Validation of the <aliases> tag.
Method testAliasTagAttributes Validation of the <alias> tag.
Method testAliasTagContent Undocumented
Method testAliasVendorTag Validation of the <vendor> tag in <alias>.
Method testAliasModelTag Validation of the <model> tag in <alias>.
Method testSoftwareTagAttributes Test the attribute validation of the <software> tag.
Method testAllowedSubtagsOfSoftware Test the validation of allowed sub-tags of <software>.
Method testInvalidContentOfSoftwareTag Test the validation of invalid content of <software>.
Method testLsbreleaseTagAttributes Test the validation of the <lsbrelease> attributes.
Method testLsbreleaseTagValidSubtag Test the validation of <lsbrelease> sub-tags.
Method testLsbreleaseTagInvalidContent Test of the validation of invalid <lsbrelease> content.
Method testPackagesTagAttributes Test of the validation of <packages> tag attributes.
Method testEmptyPackagesTag Test of the validation of <packages> tag attributes.
Method testPackagesTagWithInvalidContent Test the validation of <packages> tag attributes.
Method testPackageTagAttributes Test the validation of <package> tag attributes.
Method testPackageTagSubtags Test the validation of sub-tags of <package>.
Method testPackageTagCData Test the validation of CDATA content in <package>.
Method testXorgTagAttributes Test the validation of <xorg> attributes.
Method testXorgTagSubTags Test the validation of <xorg> sub-tags.
Method testXorgTagCData Test the validation of <xorg> CDATA content.
Method testXorgDriverTagRequiredAttributes Test the validation of attributes of <driver> within <xorg>.
Method testXorgDriverTagOptionalAttributes Test the validation of attributes of <driver> within <xorg>.
Method testXorgDriverTagInvalidAttributes Test the validation of attributes of <driver> within <xorg>.
Method testXorgDriverTagSubtags Test the validation of sub-tags of <driver> within <xorg>.
Method testXorgDriverTagCData Test the validation of sub-tags of <driver> within <xorg>.
Method testQuestionsTagAttributes Test the validation of <questions> tag attributes.
Method testQuestionsTagAttributesSubTags Test the validation of the <questions> sub-tags.
Method testQuestionsTagCData Test the validation of CDATA in <questions> tag.
Method testQuestionTagValidAttributes Test the validation of valid <question> tag attributes.
Method testQuestionTagInvalidAttributes Test the validation of invalid <question> tag attributes.
Method testQuestionTagValidSubtags Test the validation of valid <question> tag sub-tags.
Method testQuestionTagInValidSubtags Test the validation of invalid <question> tag sub-tags.
Method testAnswerCommandTag Test the validation of the <command> tag.
Method testAnswerTagAttributes Test the validation of <answer> tag attributes.
Method testAnswerTagContent Test the validation of <answer> content.
Method testAnswerChoicesTagAttributes Test the validation of <answer_choices> attributes.
Method testAnswerChoicesTagCData Test the validation of <answer_choices> CDATA content.
Method testAnswerChoicesTagSubTags Test the validation of <answer_choices> sub-tags.
Method testTargetTagAttributes Test the validation of <target> tag attributes.
Method testTargetTagCData Test the validation of <target> tag CDATA content.
Method testTargetTagValidSubtag Test the validation of the valid <target> sub-tag <driver>.
Method testTargetTagInvalidSubtag Test the validation of an invalid <target> sub-tag.
Method testTargetDriverTag Test the validation of the <driver> sub-tag of <target>.
Method testMissingContextNode Validation of the <context> node.
Method testContextNodeAttributes Validation of the <context> node attributes.
Method testContextSubnodes Validation of sub-nodes of <context>.
Method testContextNodeCData Validation of the <context> node containing CData.
Method testInfoNodeAttributes Validation of <info> attributes.
Method testInfoNodeSubnodes Validation of an <info> containing a sub-node.
Method test_natty_reports_validate Undocumented
Method _setEncoding Set the encoding in the sample data to encoding.
Method _testPropertyMissingNameAttribute The name attribute is required for all property variants.
Method _testBooleanProperty Validation of a boolean type property or value.
Method _testStringProperty Validation of a string property.
Method _testEmptyIntegerContent Detection of an empty property with integer content.
Method _testInvalidIntegerContent Detection of invalid content of a property with integer content.
Method _testMinMaxIntegerValue Detection of integer values outside of the allowed range.
Method _testIntegerProperty Validation of an integer property.
Method _testEmptyDecimalContent Detection of an empty property with number content.
Method _testInvalidDecimalContent Detection of invalid content of a property with number content.
Method _testDecimalProperty Validation of an integer property.
Method _testListAndDictPropertyCDataContent List and dict properties may not have CDATA content.
Method _wrapValue Wrap a <value> tag into a <property> tag.
Method _testBooleanValueTagValues Validation of the CDATA values of a <value> tag.
Method _setupValueTagTemplates Return templates for value tags with/without a name attribute.
Method _setupContainerTag Setup a template for a property or value tag with sub-tags.
Method _testBooleanValueTags Validation of boolean-like <value> tags.
Method _testStringValueTags Validation of string-like <value> tags.
Method _makeSampleDataForValueTag Undocumented
Method _testIntegerLimit Validation of the smallest or largest value of an int type.
Method _testIntegerValueTag Valudation of a <value> tag wwith integral content.
Method _testIntegerValueTags Validation of <value> tags with integral content.
Method _testFloatValueTag Validation of a <value> tag with float-number content.
Method _testFloatValueTags Validation of <value> tags with float-number content.
Method _testListOrDictValueTag Validation of a list or dict-like value tag.
Method _testListAndDictValueTags Validation of list and dict-like values.
Method _testValueTags Tests of <value> sub-tags of <property type="property_type">.
Method _testListOrDictProperty Validation of a list property.
Method _getXorgDriverTag Build a <driver> tag with attributes specified in "attributes."

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 runValidator(self, sample_data):
Run the Relax NG validator.

Create a unique submission ID to ensure that an error message expected in a test is indeed created by this test.

def insertSampledata(self, data, insert_text, where, after=False):
Insert text into the sample data data.

Insert the text insert_text before the first occurrence of where in data.

def replaceSampledata(self, data, replace_text, from_text, to_text):
Replace text in the sample data data.

Search for the first occurrence of from_text in data, and for the first occurrence of to_text (after from_text) in data. Replace the text between from_text and to_text by replace_text. The strings from_text are to_text are part of the text which is replaced.

def testNoXMLData(self):
The raw submission data must be XML.
def testInvalidRootNode(self):
The root node must be <system>.
def testBadDataInCommentNode(self):
Many submissions contain ESC symbols in <comment> nodes.

The cElementTree parser does not accept this; The processing script deals with this by emptying all <comment> nodes before building the element tree. (Note that we don't process data from this node at all.)

def test_fixFrequentErrors_two_comments(self):
Undocumented
def test_bad_data_does_not_oops(self):
Undocumented
def testInvalidFormatVersion(self):
The attribute format of the root node must be 1.0.
def testMissingFormatVersion(self):
The root node must have the attribute version.
def _setEncoding(self, encoding):
Set the encoding in the sample data to encoding.
def testAsciiEncoding(self):
Validation of ASCII encoded XML data.

Bytes with bit 7 set must be detected as invalid.

def testISO8859_1_Encoding(self):
XML data with ISO-8859-1 may have bytes with bit 7 set.
def testUTF8Encoding(self):
UTF-8 encoded data is properly detected and parsed.
def assertErrorMessage(self, submission_key, result, messages, test):
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.

If all three criteria match, assertErrormessage does not raise any
exception.
def testAssertErrorMessage(self):
Test the assertErrorMessage method.
def testSubtagsOfSystem(self):
The root node <system> requires a fixed set of sub-tags.
def testSummaryRequiredTags(self):
The <summary> section requires a fixed set of sub-tags.

If any of these tags is omitted, the submission data becomes invalid.

def testAdditionalSummaryTags(self):
Arbitrary tags are forbidden as sub-tags of <summary>.

The only allowed tags are specified by the Relax NG schema: live_cd, system_id, distribution, distroseries, architecture, private, contactable, date_created (tested in testSummaryRequiredTags()), and the optional tag <kernel-release>.

def testSummaryValidationOfBooleanSubtags(self):
Validation of boolean tags in the <summary> section.

These tags may only have the attribute 'value', and the value of this attribute must be 'True' or 'False'.

def testDateCreatedParsing(self):
Parsing of the date_created value.

The parser expects a valid datetime value (ISO format) in the date_created tag, like

"2007-01-01T01:02:03.400000" "2007-01-01T01:02:03Z" "2007-01-01T01:02:03:600+01:00"

The fractional part of the seconds is optional as well as the time zone information ('Z' for UTC or an offset in hh:mm).

def assertDateErrorIsDetected(self, invalid_datetime):
Run a single test for an invalid datetime.
def assertValidDateTime(self, datetime_as_string, datetime_expected):
Run a single test for a valid datetime.
def testClientTagAttributes(self):
Validation of <client> tag attributes.

The <client> tag requires the attributes 'name' and 'version'; other attributes are not allowed.

def testSubTagsOfClient(self):
The only allowed sub-tag of <client> is <plugin>.
def testClientPluginAttributes(self):
Validation of <plugin> tag attributes.

The <plugin> tag requires the attributes 'name' and 'version'; other attributes are not allowed.

def testHardwareSubTagHalOrUdev(self):
The <hardware> tag requires data about hardware devices.

This data is stored either in the sub-tag <hal> or in the three tags <udev>, <dmi>, <sysfs-attributes>.

def testHardwareSubTagUdevIncomplete(self):
The <hardware> tag has a fixed set of allowed sub-tags.

Valid sub-tags are <hal>, <udev>, <dmi>, <sysfs-attributes>, <processors>, <aliases>. <aliases> is optional, <processors> is required, and either <hal> or all three tags <udev>, <dmi>, <sysfs-attributes> must be present.

def testHardwareSubTagHalMixedWithUdev(self):
Mixing <hal> with <udev>, <dmi>, <sysfs-attributes> is impossible.
def testHardwareOtherSubTags(self):
The <hardware> tag has a fixed set of allowed sub-tags.
def testHalAttributes(self):
Validation of <hal> tag attributes.

The <hal> tag must have the 'version' attribute; other attributes are not allowed.

def testHalSubtags(self):
Validation of sub-tags of <hal>.

<hal> must contain at least one <device> sub-tag. All other sub-tags are invalid.

def testDeviceAttributes(self):
Validation of the attributes of the <device> tag.

<device> must have the attributes 'id' and 'udi'; the attribute 'parent' is optional. The latter is already shown by

<device id="130" udi="/org/freedesktop/Hal/devices/computer">

in the standard sample data.

The values of 'id' and 'parent' must be integers. "id" must not be emtpy.

def testDeviceContent(self):
<device> tags may only contain <property> tags.
def _testPropertyMissingNameAttribute(self, property):
The name attribute is required for all property variants.
def _testBooleanProperty(self, content_type):
Validation of a boolean type property or value.
def testBooleanProperties(self):
Undocumented
def _testStringProperty(self, property_type):
Validation of a string property.
def testStringProperties(self):
Validation of string properties.
def _testEmptyIntegerContent(self, property_type, relax_ng_type):
Detection of an empty property with integer content.
def _testInvalidIntegerContent(self, property_type, relax_ng_type):
Detection of invalid content of a property with integer content.
def _testMinMaxIntegerValue(self, property_type, relax_ng_type, valid_value, invalid_value):
Detection of integer values outside of the allowed range.
def _testIntegerProperty(self, property_type, relax_ng_type, min_value, max_value):
Validation of an integer property.
def testIntegerProperties(self):
Validation of integer properties.
def _testEmptyDecimalContent(self, property_type):
Detection of an empty property with number content.
def _testInvalidDecimalContent(self, property_type):
Detection of invalid content of a property with number content.
def _testDecimalProperty(self, property_type):
Validation of an integer property.
def testDecimalProperties(self):
Validation of dbus.Double and float properties.
def _testListAndDictPropertyCDataContent(self, property_type):
List and dict properties may not have CDATA content.
def assertAcceptsEmptyProperty(self, property_type):
Validation of empty list properties.
def assertRejectsNonValueSubtag(self, property_type):
Other sub-tags than <value> are not allowed in lists and dicts.
def _wrapValue(self, value_tag, property_type):
Wrap a <value> tag into a <property> tag.
def _testBooleanValueTagValues(self, property_type, tag_template):
Validation of the CDATA values of a <value> tag.
def _setupValueTagTemplates(self, value_type):
Return templates for value tags with/without a name attribute.
def assertValidatesTextValue(self, value_type, needs_name_attribute, valid_content, invalid_content, property_template):
Validation of tags with CData values
def _setupContainerTag(self, tag, name, container_type):
Setup a template for a property or value tag with sub-tags.

tag must be either 'property' or 'value'

name is the value of the name attribute of the template, or None, if the template shall not have the attribute name.

container_type must be one of 'list', 'dbus.List', 'dict', 'dbus.Dictionary'.

Return: A tag template for this property/value type and a flag, if value tags within this tag need a name attribute.

def _testBooleanValueTags(self, property_type):
Validation of boolean-like <value> tags.
def _testStringValueTags(self, property_type):
Validation of string-like <value> tags.
def _makeSampleDataForValueTag(self, property_type, value_type, value):
Undocumented
def _testIntegerLimit(self, property_type, value_type, relax_ng_type, allowed, disallowed):
Validation of the smallest or largest value of an int type.
def _testIntegerValueTag(self, property_type, value_type, relax_ng_type, min_allowed, max_allowed):
Valudation of a <value> tag wwith integral content.
def _testIntegerValueTags(self, property_type):
Validation of <value> tags with integral content.
def _testFloatValueTag(self, property_type, value_type):
Validation of a <value> tag with float-number content.
def _testFloatValueTags(self, property_type):
Validation of <value> tags with float-number content.
def _testListOrDictValueTag(self, property_type, value_type):
Validation of a list or dict-like value tag.
def _testListAndDictValueTags(self, property_type):
Validation of list and dict-like values.
def _testValueTags(self, property_type):
Tests of <value> sub-tags of <property type="property_type">.
def _testListOrDictProperty(self, property_type):
Validation of a list property.
def testListAndDictProperties(self):
Validation of dbus.Array and list properties.
def testProcessorsTag(self):
Validation of the <processors> tag.

This tag has no attributes. The only allowed sub-tag is <processor>. At least one <processor> tag must be present.

def testProcessorTag(self):
Validation of the <processors> tag.
def testAliasesTag(self):
Validation of the <aliases> tag.
def testAliasTagAttributes(self):
Validation of the <alias> tag.
def testAliasTagContent(self):
Undocumented
def testAliasVendorTag(self):
Validation of the <vendor> tag in <alias>.
def testAliasModelTag(self):
Validation of the <model> tag in <alias>.
def testSoftwareTagAttributes(self):
Test the attribute validation of the <software> tag.
def testAllowedSubtagsOfSoftware(self):
Test the validation of allowed sub-tags of <software>.
def testInvalidContentOfSoftwareTag(self):
Test the validation of invalid content of <software>.
def testLsbreleaseTagAttributes(self):
Test the validation of the <lsbrelease> attributes.
def testLsbreleaseTagValidSubtag(self):
Test the validation of <lsbrelease> sub-tags.
def testLsbreleaseTagInvalidContent(self):
Test of the validation of invalid <lsbrelease> content.
def testPackagesTagAttributes(self):
Test of the validation of <packages> tag attributes.
def testEmptyPackagesTag(self):
Test of the validation of <packages> tag attributes.
def testPackagesTagWithInvalidContent(self):
Test the validation of <packages> tag attributes.
def testPackageTagAttributes(self):
Test the validation of <package> tag attributes.
def testPackageTagSubtags(self):
Test the validation of sub-tags of <package>.
def testPackageTagCData(self):
Test the validation of CDATA content in <package>.
def testXorgTagAttributes(self):
Test the validation of <xorg> attributes.
def testXorgTagSubTags(self):
Test the validation of <xorg> sub-tags.
def testXorgTagCData(self):
Test the validation of <xorg> CDATA content.
def _getXorgDriverTag(self, attributes):
Build a <driver> tag with attributes specified in "attributes."
def testXorgDriverTagRequiredAttributes(self):
Test the validation of attributes of <driver> within <xorg>.

The attributes "name" and "class" are required.

def testXorgDriverTagOptionalAttributes(self):
Test the validation of attributes of <driver> within <xorg>.

The attributes "device" and "version" are optional.

def testXorgDriverTagInvalidAttributes(self):
Test the validation of attributes of <driver> within <xorg>.

Attributes other than name, version, class, device are invalid.

def testXorgDriverTagSubtags(self):
Test the validation of sub-tags of <driver> within <xorg>.
def testXorgDriverTagCData(self):
Test the validation of sub-tags of <driver> within <xorg>.
def testQuestionsTagAttributes(self):
Test the validation of <questions> tag attributes.
def testQuestionsTagAttributesSubTags(self):
Test the validation of the <questions> sub-tags.
def testQuestionsTagCData(self):
Test the validation of CDATA in <questions> tag.
def testQuestionTagValidAttributes(self):
Test the validation of valid <question> tag attributes.
def testQuestionTagInvalidAttributes(self):
Test the validation of invalid <question> tag attributes.
def testQuestionTagValidSubtags(self):
Test the validation of valid <question> tag sub-tags.
def testQuestionTagInValidSubtags(self):
Test the validation of invalid <question> tag sub-tags.
def testAnswerCommandTag(self):
Test the validation of the <command> tag.
def testAnswerTagAttributes(self):
Test the validation of <answer> tag attributes.
def testAnswerTagContent(self):
Test the validation of <answer> content.
def testAnswerChoicesTagAttributes(self):
Test the validation of <answer_choices> attributes.
def testAnswerChoicesTagCData(self):
Test the validation of <answer_choices> CDATA content.
def testAnswerChoicesTagSubTags(self):
Test the validation of <answer_choices> sub-tags.
def testTargetTagAttributes(self):
Test the validation of <target> tag attributes.
def testTargetTagCData(self):
Test the validation of <target> tag CDATA content.
def testTargetTagValidSubtag(self):
Test the validation of the valid <target> sub-tag <driver>.
def testTargetTagInvalidSubtag(self):
Test the validation of an invalid <target> sub-tag.
def testTargetDriverTag(self):
Test the validation of the <driver> sub-tag of <target>.
def testMissingContextNode(self):
Validation of the <context> node.
def testContextNodeAttributes(self):
Validation of the <context> node attributes.
def testContextSubnodes(self):
Validation of sub-nodes of <context>.
def testContextNodeCData(self):
Validation of the <context> node containing CData.
def testInfoNodeAttributes(self):
Validation of <info> attributes.
def testInfoNodeSubnodes(self):
Validation of an <info> containing a sub-node.
def test_natty_reports_validate(self):
Undocumented
API Documentation for Launchpad, generated by pydoctor at 2018-02-25 00:00:04.