def test_valid_xml(self): """initialize_xml should turn a string of valid XML into an object.""" valid_xml_file = StringIO(PfifXml.XML_11_SMALL) tree = utils.PfifXmlTree(valid_xml_file) self.assertTrue(tree) self.assertTrue(tree.lines) self.assertTrue(tree.line_numbers)
def objectify_pfif_xml(file_to_objectify, ignore_fields=None, omit_blank_fields=False): """Turns a file of PFIF XML into a map.""" # read the file into an XML tree tree = utils.PfifXmlTree(file_to_objectify) # turn the xml trees into a persons and notes map for each file. They will # map from record_id to a map from field_name to value object_map = {} objectify_parents(tree.get_all_persons(), True, object_map, tree, ignore_fields=ignore_fields, omit_blank_fields=omit_blank_fields) objectify_parents(tree.get_top_level_notes(), False, object_map, tree, ignore_fields=ignore_fields, omit_blank_fields=omit_blank_fields) return object_map
def test_root_is_pfif(self): """initialize_pfif_version should return the version if the root is PFIF.""" pfif_11_xml_file = StringIO(PfifXml.XML_11_SMALL) tree = utils.PfifXmlTree(pfif_11_xml_file) self.assertEqual(tree.version, 1.1)
def __init__(self, xml_file): self.tree = utils.PfifXmlTree(xml_file) self.version = self.tree.version