Beispiel #1
0
def test_parse_cals_tgroup__overrides_table():
    # --without namespaces
    parser = CalsParser(BaseBuilder())
    parser.setup_table(
        {
            "x-cell-border-right": BORDER_NONE,
            "x-cell-border-bottom": BORDER_NONE,
            "x-sect-orient": "landscape",
            "x-sect-cols": "1",
            "background-color": "velvet",
        },
        "TableOld",
    )
    cals_tgroup_attrib = {
        "colsep": "1",
        "rowsep": "1",
        "tgroupstyle": "TableNew"
    }
    cals_tgroup = etree.Element("tgroup", attrib=cals_tgroup_attrib)
    state = parser.parse_cals_tgroup(cals_tgroup)
    table = state.table
    assert table.styles == {
        "x-cell-border-right": BORDER_SOLID,
        "x-cell-border-bottom": BORDER_SOLID,
        "x-sect-orient": "landscape",  # preserved
        "x-sect-cols": "1",  # preserved
        "background-color": "velvet",  # preserved
    }
    assert table.nature == "TableNew"
Beispiel #2
0
def test_parse_cals_tgroup(attrib, styles, nature):
    # --without namespaces
    cals_tgroup = etree.Element("tgroup", attrib=attrib)
    parser = CalsParser(BaseBuilder())
    parser.setup_table()
    state = parser.parse_cals_tgroup(cals_tgroup)
    table = state.table
    assert table.styles == styles
    assert table.nature == nature

    # --with default namespaces
    cals_tgroup_attrib = {cals(k): v for k, v in attrib.items()}
    cals_tgroup = etree.Element(cals("tgroup"),
                                attrib=cals_tgroup_attrib,
                                nsmap={None: CALS_NS})
    parser = CalsParser(BaseBuilder(), cals_ns=CALS_NS)
    parser.setup_table()
    state = parser.parse_cals_tgroup(cals_tgroup)
    table = state.table
    assert table.styles == styles
    assert table.nature == nature