Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
 def test_from_xml(self, ParagraphProperties):
     src = """
     <pPr />
     """
     node = fromstring(src)
     text = ParagraphProperties.from_tree(node)
     assert text == ParagraphProperties()
Ejemplo n.º 4
0
 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
Ejemplo n.º 5
0
 def test_from_xml(self, LineBreak):
     src = """
     <br />
     """
     node = fromstring(src)
     fut = LineBreak.from_tree(node)
     assert fut == LineBreak()
Ejemplo n.º 6
0
 def test_from_xml(self, Paragraph):
     src = """
     <p />
     """
     node = fromstring(src)
     text = Paragraph.from_tree(node)
     assert text == Paragraph()
Ejemplo n.º 7
0
 def test_from_xml(self, CharacterProperties):
     src = """
     <defRPr sz="110"/>
     """
     node = fromstring(src)
     text = CharacterProperties.from_tree(node)
     assert text == CharacterProperties(sz=110)
Ejemplo n.º 8
0
 def test_from_xml(self, PivotField):
     src = """
     <pivotField />
     """
     node = fromstring(src)
     field = PivotField.from_tree(node)
     assert field == PivotField()
Ejemplo n.º 9
0
 def test_from_xml(self, PictureLocking):
     src = """
     <picLocks noRot="1" />
     """
     node = fromstring(src)
     graphic = PictureLocking.from_tree(node)
     assert graphic == PictureLocking(noRot=1)
Ejemplo n.º 10
0
 def test_from_xml(self, NonVisualPictureProperties):
     src = """
     <cNvPicPr />
     """
     node = fromstring(src)
     graphic = NonVisualPictureProperties.from_tree(node)
     assert graphic == NonVisualPictureProperties()
Ejemplo n.º 11
0
 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
Ejemplo n.º 12
0
 def test_from_xml(self, Title):
     src = """
     <title />
     """
     node = fromstring(src)
     title = Title.from_tree(node)
     assert title == Title()
Ejemplo n.º 13
0
 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]
Ejemplo n.º 14
0
 def test_from_xml(self, BandFormatList):
     src = """
     <bandFmts />
     """
     node = fromstring(src)
     fmt = BandFormatList.from_tree(node)
     assert fmt == BandFormatList()
Ejemplo n.º 15
0
 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")
Ejemplo n.º 16
0
 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)
Ejemplo n.º 17
0
 def test_no_name(self, PivotTableStyle):
     src = """
     <pivotTableStyleInfo />
     """
     node = fromstring(src)
     style = PivotTableStyle.from_tree(node)
     assert style == PivotTableStyle()
Ejemplo n.º 18
0
 def test_from_xml(self, RichText):
     src = """
     <rich />
     """
     node = fromstring(src)
     text = RichText.from_tree(node)
     assert text == RichText()
Ejemplo n.º 19
0
 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"
Ejemplo n.º 20
0
    def test_tag_mismatch(self, NestedValue):

        xml = """
        <length val="4"></length>
        """
        node = fromstring(xml)
        with pytest.raises(ValueError):
            simple = NestedValue(size=node)
Ejemplo n.º 21
0
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
Ejemplo n.º 22
0
    def test_from_tree(self, CustomAttribute):

        xml = """
        <size something="4"></size>
        """
        node = fromstring(xml)
        simple = CustomAttribute(size=node)
        assert simple.size == 4
Ejemplo n.º 23
0
    def test_from_tree(self, NestedValue):

        xml = """
            <size val="4"></size>
            """
        node = fromstring(xml)
        simple = NestedValue(size=node)
        assert simple.size == 4
Ejemplo n.º 24
0
    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
Ejemplo n.º 25
0
    def test_from_tree(self, NestedText):
        xml = """
            <coord>4</coord>
            """
        node = fromstring(xml)

        simple = NestedText(node)
        assert simple.coord == 4
Ejemplo n.º 26
0
 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()
Ejemplo n.º 27
0
 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
Ejemplo n.º 28
0
 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
Ejemplo n.º 29
0
 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)
Ejemplo n.º 30
0
 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")