def chart_fixture(self, request, chart_part_, graphicFrame_, chart_):
     property_mock(request,
                   GraphicFrame,
                   "chart_part",
                   return_value=chart_part_)
     graphic_frame = GraphicFrame(graphicFrame_, None)
     return graphic_frame, chart_
Esempio n. 2
0
    def it_provides_access_to_the_chart_it_contains(
        self, request, has_chart_prop_, chart_part_, chart_
    ):
        has_chart_prop_.return_value = True
        property_mock(request, GraphicFrame, "chart_part", return_value=chart_part_)
        chart_part_.chart = chart_

        assert GraphicFrame(None, None).chart is chart_
Esempio n. 3
0
 def it_knows_its_shape_type(self, uri, oleObj_child, expected_value):
     graphicFrame = element(
         (
             "p:graphicFrame/a:graphic/a:graphicData{uri=%s}/p:oleObj/p:%s"
             % (uri, oleObj_child)
         )
         if oleObj_child
         else "p:graphicFrame/a:graphic/a:graphicData{uri=%s}" % uri
     )
     assert GraphicFrame(graphicFrame, None).shape_type is expected_value
Esempio n. 4
0
 def but_it_raises_on_ole_format_when_this_is_not_an_OLE_object(self):
     graphic_frame = GraphicFrame(
         element(
             "p:graphicFrame/a:graphic/a:graphicData{uri=http://schemas.openxmlfor"
             "mats.org/drawingml/2006/table}"),
         None,
     )
     with pytest.raises(ValueError) as e:
         graphic_frame.ole_format
     assert str(e.value) == "not an OLE-object shape"
Esempio n. 5
0
    def it_provides_access_to_its_chart_part(self, request, chart_part_):
        slide_part_ = instance_mock(request, SlidePart)
        slide_part_.related_part.return_value = chart_part_
        property_mock(request, GraphicFrame, "part", return_value=slide_part_)
        graphic_frame = GraphicFrame(
            element(
                "p:graphicFrame/a:graphic/a:graphicData/c:chart{r:id=rId42}"),
            None)

        chart_part = graphic_frame.chart_part

        slide_part_.related_part.assert_called_once_with("rId42")
        assert chart_part is chart_part_
Esempio n. 6
0
    def it_provides_access_to_its_chart_part(self, request, chart_part_):
        graphicFrame = element(
            "p:graphicFrame/a:graphic/a:graphicData/c:chart{r:id=rId42}"
        )
        property_mock(
            request,
            GraphicFrame,
            "part",
            return_value=instance_mock(
                request, SlidePart, related_parts={"rId42": chart_part_}
            ),
        )
        graphic_frame = GraphicFrame(graphicFrame, None)

        assert graphic_frame.chart_part is chart_part_
Esempio n. 7
0
    def it_provides_access_to_the_OleFormat_object(self, request):
        ole_format_ = instance_mock(request, _OleFormat)
        _OleFormat_ = class_mock(request,
                                 "pptx.shapes.graphfrm._OleFormat",
                                 return_value=ole_format_)
        graphicFrame = element(
            "p:graphicFrame/a:graphic/a:graphicData{uri=http://schemas.openxmlformats"
            ".org/presentationml/2006/ole}")
        parent_ = instance_mock(request, SlideShapes)
        graphic_frame = GraphicFrame(graphicFrame, parent_)

        ole_format = graphic_frame.ole_format

        _OleFormat_.assert_called_once_with(graphicFrame.graphicData, parent_)
        assert ole_format is ole_format_
 def has_table_fixture(self, request):
     uri, expected_value = request.param
     graphicFrame = element(
         "p:graphicFrame/a:graphic/a:graphicData{uri=%s}" % uri)
     graphic_frame = GraphicFrame(graphicFrame, None)
     return graphic_frame, expected_value
 def chart_part_fixture(self, parent_, chart_part_):
     graphicFrame_cxml = "p:graphicFrame/a:graphic/a:graphicData/c:chart{r:id=rId42}"
     graphic_frame = GraphicFrame(element(graphicFrame_cxml), parent_)
     return graphic_frame, chart_part_
 def chart_raise_fixture(self, request, graphicFrame_):
     graphicFrame_.has_chart = False
     graphic_frame = GraphicFrame(graphicFrame_, None)
     return graphic_frame
 def it_raises_on_shadow(self):
     graphic_frame = GraphicFrame(None, None)
     with pytest.raises(NotImplementedError):
         graphic_frame.shadow
Esempio n. 12
0
 def it_knows_whether_it_contains_a_table(self, graphicData_uri, expected_value):
     graphicFrame = element(
         "p:graphicFrame/a:graphic/a:graphicData{uri=%s}" % graphicData_uri
     )
     assert GraphicFrame(graphicFrame, None).has_table is expected_value
Esempio n. 13
0
    def but_it_raises_on_chart_if_there_isnt_one(self, has_chart_prop_):
        has_chart_prop_.return_value = False

        with pytest.raises(ValueError) as e:
            GraphicFrame(None, None).chart
        assert str(e.value) == "shape does not contain a chart"