TMSS-761: Check if the types of complexTypes like CorrelatedDataproduct,...
TMSS-761: Check if the types of complexTypes like CorrelatedDataproduct, Observation, etc are annotated using xml attributes. The LTA catalogue code expects these attributes like xsi:type="sip:CorrelatedDataProduct"
@@ -637,6 +636,43 @@ class TestSIPlib(unittest.TestCase):
...
@@ -637,6 +636,43 @@ class TestSIPlib(unittest.TestCase):
mysip.save_to_file(TMPFILE_PATH)
mysip.save_to_file(TMPFILE_PATH)
self.assertTrue(validator.validate(TMPFILE_PATH))
self.assertTrue(validator.validate(TMPFILE_PATH))
deftest_type_attributes(self):
'''Check if the types of complexTypes like CorrelatedDataproduct, Observation, etc are annotated using xml attributes.
The LTA catalogue code expects these attributes like xsi:type="sip:CorrelatedDataProduct"'''
mysip=create_basicdoc()
mysip.add_observation(create_observation())
xml_doc=mysip.get_prettyxml()
logger.info(xml_doc)
# The LTA catalogue code expects these attributes like xsi:type="sip:CorrelatedDataProduct"
# So, use etree XML DOM parsing for correct lookup of the interesting elements,
# but also check explicitly if the attribute as plain text is as the LTA code expects it.
# (There many ways to use a namespace, and parsers like etree have a tendency to interpret the plain text and substitute abbreviations with fqdn namespaces)
xml_root=etree.fromstring(xml_doc)# for DOM parsing
xml_lines=xml_doc.split('\n')# for plain text parsing