from lxml import etree as ET from qurator.modstool.mods4pandas import mets_to_dict from qurator.modstool.lib import flatten def dict_fromstring(x): """Helper function to parse a METS/MODS XML string to a flattened dict""" return flatten(mets_to_dict(ET.fromstring(x))) # XXX move to test lib def test_fileGrp(): """ Elements of mets:fileGrp should be counted """ d = dict_fromstring(""" """) assert d['fileSec_fileGrp-PRESENTATION-count'] == 3