use lxml, factor PAGE creation to utils.xml

This commit is contained in:
Konstantin Baierer 2020-12-11 13:23:56 +01:00
parent 14d80700d4
commit ff7b5ce409
3 changed files with 52 additions and 52 deletions

11
tests/test_xml.py Normal file
View file

@ -0,0 +1,11 @@
from lxml import etree as ET
from sbb_newspapers_org_image.utils.xml import create_page_xml, NAMESPACES
def tostring(el):
return ET.tostring(el).decode('utf-8')
def test_create_xml():
pcgts, page = create_page_xml('/path/to/img.tif', 100, 100)
xmlstr = tostring(pcgts)
assert 'xmlns="%s"' % NAMESPACES[None] in xmlstr
assert 'Metadata' in xmlstr