def test_from_xml(self, DataField): src = """ <dataField name="Sum of impressions" fld="4" baseField="0" baseItem="0"/> """ node = fromstring(src) df = DataField.from_tree(node) assert df == DataField(fld=4, name="Sum of impressions", baseField=0, baseItem=0)
def test_from_xml(self, Location): src = """ <location ref="A3:E14" firstHeaderRow="1" firstDataRow="2" firstDataCol="1"/> """ node = fromstring(src) loc = Location.from_tree(node) assert loc == Location(ref="A3:E14", firstHeaderRow=1, firstDataRow=2, firstDataCol=1)
def test_from_xml(self, ParagraphProperties): src = """ <pPr /> """ node = fromstring(src) text = ParagraphProperties.from_tree(node) assert text == ParagraphProperties()
def test_from_xml(self, ConnectorShape): src = """ <cxnSp xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" macro=""> <nvCxnSpPr> <cNvPr id="3" name="Straight Arrow Connector 2"> </cNvPr> <cNvCxnSpPr/> </nvCxnSpPr> <spPr> <a:xfrm flipH="1" flipV="1"> <a:off x="3321050" y="3829050"/> <a:ext cx="165100" cy="368300"/> </a:xfrm> <a:prstGeom prst="straightConnector1"> <a:avLst/> </a:prstGeom> <a:ln> <a:tailEnd type="triangle"/> </a:ln> </spPr> </cxnSp> """ node = fromstring(src) cnx = ConnectorShape.from_tree(node) assert cnx.nvCxnSpPr.cNvPr.id == 3
def test_from_xml(self, LineBreak): src = """ <br /> """ node = fromstring(src) fut = LineBreak.from_tree(node) assert fut == LineBreak()
def test_from_xml(self, Paragraph): src = """ <p /> """ node = fromstring(src) text = Paragraph.from_tree(node) assert text == Paragraph()
def test_from_xml(self, CharacterProperties): src = """ <defRPr sz="110"/> """ node = fromstring(src) text = CharacterProperties.from_tree(node) assert text == CharacterProperties(sz=110)
def test_from_xml(self, PivotField): src = """ <pivotField /> """ node = fromstring(src) field = PivotField.from_tree(node) assert field == PivotField()
def test_from_xml(self, PictureLocking): src = """ <picLocks noRot="1" /> """ node = fromstring(src) graphic = PictureLocking.from_tree(node) assert graphic == PictureLocking(noRot=1)
def test_from_xml(self, NonVisualPictureProperties): src = """ <cNvPicPr /> """ node = fromstring(src) graphic = NonVisualPictureProperties.from_tree(node) assert graphic == NonVisualPictureProperties()
def test_from_xml(self, PictureFrame): src = """ <pic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"> <nvPicPr> <cNvPr descr="Picture" id="1" name="Image 1"/> <cNvPicPr/> </nvPicPr> <blipFill> <a:blip xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" cstate="print" r:embed="rId1"/> <a:stretch> <a:fillRect/> </a:stretch> </blipFill> <spPr> <a:xfrm> <a:off x="303" y="0"/> <a:ext cx="321" cy="88"/> </a:xfrm> <a:prstGeom prst="rect"/> <a:ln> <a:prstDash val="solid" /> </a:ln> </spPr> </pic> """ node = fromstring(src) graphic = PictureFrame.from_tree(node) xml = tostring(graphic.to_tree()) diff = compare_xml(xml, src) assert diff is None, diff
def test_from_xml(self, Title): src = """ <title /> """ node = fromstring(src) title = Title.from_tree(node) assert title == Title()
def test_from_xml(self, SurfaceChart3D): src = """ <surface3DChart> <wireframe val="0"/> <ser> <idx val="0"/> <order val="0"/> <val> <numRef> <f>Blatt1!$A$1:$A$12</f> </numRef> </val> </ser> <ser> <idx val="1"/> <order val="1"/> <val> <numRef> <f>Blatt1!$B$1:$B$12</f> </numRef> </val> </ser> <bandFmts/> <axId val="2082935272"/> <axId val="2082938248"/> <axId val="2082941288"/> </surface3DChart> """ node = fromstring(src) chart = SurfaceChart3D.from_tree(node) assert len(chart.ser) == 2 assert chart.axId == [2082935272, 2082938248, 2082941288]
def test_from_xml(self, BandFormatList): src = """ <bandFmts /> """ node = fromstring(src) fmt = BandFormatList.from_tree(node) assert fmt == BandFormatList()
def test_from_xml(self, Hyperlink): src = """ <hlinkClick tooltip="Select/de-select all"/> """ node = fromstring(src) link = Hyperlink.from_tree(node) assert link == Hyperlink(tooltip="Select/de-select all")
def test_from_xml(self, PageField): src = """ <pageField fld="64" hier="-1"/> """ node = fromstring(src) pf = PageField.from_tree(node) assert pf == PageField(fld=64, hier=-1)
def test_no_name(self, PivotTableStyle): src = """ <pivotTableStyleInfo /> """ node = fromstring(src) style = PivotTableStyle.from_tree(node) assert style == PivotTableStyle()
def test_from_xml(self, RichText): src = """ <rich /> """ node = fromstring(src) text = RichText.from_tree(node) assert text == RichText()
def test_read_scatter_chart(self, PlotArea, datadir): datadir.chdir() with open("3D_plotarea.xml", "rb") as src: tree = fromstring(src.read()) plot = PlotArea.from_tree(tree) chart = plot._charts[0] assert chart.axId == [10, 100, 1000] assert chart.tagname == "surface3DChart"
def test_tag_mismatch(self, NestedValue): xml = """ <length val="4"></length> """ node = fromstring(xml) with pytest.raises(ValueError): simple = NestedValue(size=node)
def test_from_tree(datadir, SampleProperties): datadir.chdir() with open("core.xml") as src: content = src.read() content = fromstring(content) props = SampleProperties.from_tree(content) assert props == SampleProperties
def test_from_tree(self, CustomAttribute): xml = """ <size something="4"></size> """ node = fromstring(xml) simple = CustomAttribute(size=node) assert simple.size == 4
def test_from_tree(self, NestedValue): xml = """ <size val="4"></size> """ node = fromstring(xml) simple = NestedValue(size=node) assert simple.size == 4
def test_read(self, CacheDefinition, datadir): datadir.chdir() with open("pivotCacheDefinition.xml", "rb") as src: xml = fromstring(src.read()) cache = CacheDefinition.from_tree(xml) assert cache.recordCount == 17 assert len(cache.cacheFields) == 6
def test_from_tree(self, NestedText): xml = """ <coord>4</coord> """ node = fromstring(xml) simple = NestedText(node) assert simple.coord == 4
def test_from_xml(self, GraphicObject): src = """ <graphic> <graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/chart"></graphicData> </graphic> """ node = fromstring(src) graphic = GraphicObject.from_tree(node) assert graphic == GraphicObject()
def test_get(self, DefinedNameList, datadir, name, scope, result): datadir.chdir() with open("workbook.xml", "rb") as src: xml = src.read() node = fromstring(xml) dl = DefinedNameList.from_tree(node) check = dl.get(name, scope) is not None assert check is result
def test_merge_named_styles(self, Stylesheet, datadir): datadir.chdir() with open("complex-styles.xml") as src: xml = src.read() node = fromstring(xml) stylesheet = Stylesheet.from_tree(node) named_styles = stylesheet._merge_named_styles() assert len(named_styles) == 3
def test_from_xml(self, TableStyleInfo): src = """ <tableStyleInfo name="TableStyleLight1" showRowStripes="1" /> """ node = fromstring(src) info = TableStyleInfo.from_tree(node) assert info == TableStyleInfo(name="TableStyleLight1", showRowStripes=True)
def test_from_xml(self, FileExtension): src = """ <Default ContentType="application/xml" Extension="xml"/> """ node = fromstring(src) ext = FileExtension.from_tree(node) assert ext == FileExtension(ContentType="application/xml", Extension="xml")