def test_parse_fmx_ti_blk__level2__with_namespace(): def fmx(name): return etree.QName(FORMEX_NS, name).text BLK = fmx("BLK") TI_BLK = fmx("TI.BLK") IE = fmx("IE") fmx_blk1 = etree.Element(BLK, nsmap={None: FORMEX_NS}) fmx_blk2 = etree.SubElement(fmx_blk1, BLK, nsmap={None: FORMEX_NS}) fmx_ti_blk = etree.SubElement(fmx_blk2, TI_BLK, nsmap={None: FORMEX_NS}) etree.SubElement(fmx_ti_blk, IE, nsmap={None: FORMEX_NS}) parser = FormexParser(BaseBuilder(), formex_ns=FORMEX_NS, cals_prefix=CALS_PREFIX, cals_ns=CALS_NS) state = parser.setup_table() state.next_row() state = parser.parse_fmx_ti_blk(fmx_ti_blk) row = state.row assert row.styles == {"rowstyle": "TI.BLK-level2"} assert row.nature == "body" table = state.table cell = table[(1, 1)] assert cell.styles == {} assert cell.nature == "body" assert cell.width == 1 assert cell.height == 1 assert cell.content == ""
def test_parse_fmx_ti_blk__level1(): fmx_blk = etree.Element("BLK") fmx_ti_blk = etree.XML( """<TI.BLK COL.START="1" COL.END="2" valign="top" rowsep="1" bgcolor="blue"><P>paragraph</P></TI.BLK>""" ) fmx_blk.append(fmx_ti_blk) parser = FormexParser(BaseBuilder()) state = parser.setup_table() state.next_row() state = parser.parse_fmx_ti_blk(fmx_ti_blk) row = state.row assert row.styles == { 'background-color': 'blue', 'border-bottom': 'solid 1pt black', 'rowstyle': 'TI.BLK-level1', 'vertical-align': 'top', } assert row.nature == "body" table = state.table cell = table[(1, 1)] assert cell.styles == {} assert cell.nature == "body" assert cell.width == 2 assert cell.height == 1 assert etree.tounicode(cell.content[0]) == "<P>paragraph</P>"
def test_parse_fmx_ti_blk__level2(): fmx_blk = etree.Element("BLK") fmx_blk = etree.SubElement(fmx_blk, "BLK") fmx_ti_blk = etree.XML("""<TI.BLK><IE/></TI.BLK>""") fmx_blk.append(fmx_ti_blk) parser = FormexParser(BaseBuilder()) state = parser.setup_table() state.next_row() state = parser.parse_fmx_ti_blk(fmx_ti_blk) row = state.row assert row.styles == {"rowstyle": "TI.BLK-level2"} assert row.nature == "body" table = state.table cell = table[(1, 1)] assert cell.styles == {} assert cell.nature == "body" assert cell.width == 1 assert cell.height == 1 assert cell.content == ""