Esempio n. 1
0
    def it_adds_a_notes_slide_part_to_help(self, package_, NotesSlidePart_,
                                           notes_slide_part_, relate_to_):
        NotesSlidePart_.new.return_value = notes_slide_part_
        slide_part = SlidePart(None, None, None, package_)

        notes_slide_part = slide_part._add_notes_slide_part()

        assert notes_slide_part is notes_slide_part_
        NotesSlidePart_.new.assert_called_once_with(package_, slide_part)
        relate_to_.assert_called_once_with(slide_part, notes_slide_part,
                                           RT.NOTES_SLIDE)
Esempio n. 2
0
    def it_can_add_a_chart_part(self, request, package_, relate_to_):
        chart_data_ = instance_mock(request, ChartData)
        chart_part_ = instance_mock(request, ChartPart)
        ChartPart_ = class_mock(request, "pptx.parts.slide.ChartPart")
        ChartPart_.new.return_value = chart_part_
        relate_to_.return_value = "rId42"
        slide_part = SlidePart(None, None, package_, None)

        rId = slide_part.add_chart_part(XCT.RADAR, chart_data_)

        ChartPart_.new.assert_called_once_with(XCT.RADAR, chart_data_, package_)
        relate_to_.assert_called_once_with(slide_part, chart_part_, RT.CHART)
        assert rId == "rId42"
Esempio n. 3
0
    def it_can_get_or_add_a_video_part(self, package_, video_, relate_to_, media_part_):
        media_rId, video_rId = "rId1", "rId2"
        package_.get_or_add_media_part.return_value = media_part_
        relate_to_.side_effect = [media_rId, video_rId]
        slide_part = SlidePart(None, None, package_, None)

        result = slide_part.get_or_add_video_media_part(video_)

        package_.get_or_add_media_part.assert_called_once_with(video_)
        assert relate_to_.call_args_list == [
            call(slide_part, media_part_, RT.MEDIA),
            call(slide_part, media_part_, RT.VIDEO),
        ]
        assert result == (media_rId, video_rId)
 def rename_fixture(self, related_parts_prop_):
     prs_part = PresentationPart(None, None, None)
     rIds = ('rId1', 'rId2')
     getitem_ = related_parts_prop_.return_value.__getitem__
     calls = [call('rId1'), call('rId2')]
     slide_parts = [
         SlidePart(None, None, None),
         SlidePart(None, None, None),
     ]
     expected_names = [
         PackURI('/ppt/slides/slide1.xml'),
         PackURI('/ppt/slides/slide2.xml'),
     ]
     getitem_.side_effect = slide_parts
     return (prs_part, rIds, getitem_, calls, slide_parts, expected_names)
Esempio n. 5
0
 def add_chart_part_fixture(self, package_, chart_type_, chart_data_,
                            ChartPart_, chart_part_, relate_to_):
     slide_part = SlidePart(None, None, None, package_)
     ChartPart_.new.return_value = chart_part_
     relate_to_.return_value = rId = 'rId42'
     return (slide_part, chart_type_, chart_data_, ChartPart_, chart_part_,
             package_, rId)
Esempio n. 6
0
 def goa_video_fixture(self, package_, video_, relate_to_, media_part_):
     slide_part = SlidePart(None, None, None, package_)
     calls = [call(media_part_, RT.MEDIA), call(media_part_, RT.VIDEO)]
     media_rId, video_rId = "rId1", "rId2"
     package_.get_or_add_media_part.return_value = media_part_
     relate_to_.side_effect = [media_rId, video_rId]
     return (slide_part, video_, package_, relate_to_, calls, media_rId,
             video_rId)
Esempio n. 7
0
 def add_slide(self, slide_layout):
     """
     Return an (rId, slide) pair of a newly created blank slide that
     inherits appearance from *slide_layout*.
     """
     partname = self._next_slide_partname
     slide_layout_part = slide_layout.part
     slide_part = SlidePart.new(partname, self.package, slide_layout_part)
     rId = self.relate_to(slide_part, RT.SLIDE)
     return rId, slide_part.slide
Esempio n. 8
0
 def notes_slide_fixture(self, request, notes_slide_, part_related_by_,
                         _add_notes_slide_part_, notes_slide_part_):
     has_notes_slide = request.param
     slide_part = SlidePart(None, None, None, None)
     part_related_by_.return_value = notes_slide_part_
     add_calls = []
     if not has_notes_slide:
         part_related_by_.side_effect = KeyError
         add_calls.append(call(slide_part))
     notes_slide_part_.notes_slide = notes_slide_
     return slide_part, add_calls, notes_slide_
Esempio n. 9
0
    def it_can_create_a_new_slide_part(self, new_fixture):
        slide_layout_part_, partname, package_ = new_fixture[:3]
        SlidePart_init_, sld = new_fixture[3:]

        slide_part = SlidePart.new(partname, package_, slide_layout_part_)

        SlidePart_init_.assert_called_once_with(partname, CT.PML_SLIDE, sld, package_)
        slide_part.relate_to.assert_called_once_with(
            slide_layout_part_, RT.SLIDE_LAYOUT
        )
        assert isinstance(slide_part, SlidePart)
Esempio n. 10
0
    def it_can_create_a_new_slide_part(self, new_fixture):
        slide_layout_part_, partname, package_ = new_fixture[:3]
        SlidePart_init_, sld = new_fixture[3:]

        slide_part = SlidePart.new(partname, package_, slide_layout_part_)

        SlidePart_init_.assert_called_once_with(partname, CT.PML_SLIDE, sld,
                                                package_)
        slide_part.relate_to.assert_called_once_with(slide_layout_part_,
                                                     RT.SLIDE_LAYOUT)
        assert isinstance(slide_part, SlidePart)
Esempio n. 11
0
    def it_can_add_an_embedded_ole_object_part(
        self, request, package_, relate_to_, prog_id, rel_type
    ):
        _blob_from_file_ = method_mock(
            request, SlidePart, "_blob_from_file", return_value=b"012345"
        )
        embedded_package_part_ = instance_mock(request, EmbeddedPackagePart)
        EmbeddedPackagePart_ = class_mock(
            request, "pptx.parts.slide.EmbeddedPackagePart"
        )
        EmbeddedPackagePart_.factory.return_value = embedded_package_part_
        relate_to_.return_value = "rId9"
        slide_part = SlidePart(None, None, package_, None)

        _rId = slide_part.add_embedded_ole_object_part(prog_id, "workbook.xlsx")

        _blob_from_file_.assert_called_once_with(slide_part, "workbook.xlsx")
        EmbeddedPackagePart_.factory.assert_called_once_with(
            prog_id, b"012345", package_
        )
        relate_to_.assert_called_once_with(slide_part, embedded_package_part_, rel_type)
        assert _rId == "rId9"
Esempio n. 12
0
    def it_can_create_a_new_slide_part(self, request, package_, relate_to_):
        partname = PackURI("/foobar.xml")
        SlidePart_init_ = initializer_mock(request, SlidePart)
        slide_layout_part_ = instance_mock(request, SlideLayoutPart)
        CT_Slide_ = class_mock(request, "pptx.parts.slide.CT_Slide")
        CT_Slide_.new.return_value = sld = element("c:sld")

        slide_part = SlidePart.new(partname, package_, slide_layout_part_)

        SlidePart_init_.assert_called_once_with(partname, CT.PML_SLIDE, sld,
                                                package_)
        slide_part.relate_to.assert_called_once_with(slide_part,
                                                     slide_layout_part_,
                                                     RT.SLIDE_LAYOUT)
        assert isinstance(slide_part, SlidePart)
Esempio n. 13
0
 def slide_id_fixture(self, package_, presentation_part_):
     slide_part = SlidePart(None, None, None, package_)
     slide_id = 256
     package_.presentation_part = presentation_part_
     presentation_part_.slide_id.return_value = slide_id
     return slide_part, presentation_part_, slide_id
Esempio n. 14
0
 def slide_fixture(self, Slide_, slide_):
     sld = element("p:sld")
     slide_part = SlidePart(None, None, sld, None)
     return slide_part, Slide_, sld, slide_
Esempio n. 15
0
 def layout_fixture(self, slide_layout_, part_related_by_):
     slide_part = SlidePart(None, None, None, None)
     part_related_by_.return_value.slide_layout = slide_layout_
     return slide_part, slide_layout_
Esempio n. 16
0
 def has_notes_slide_fixture(self, request, part_related_by_):
     has_notes_slide = request.param
     slide_part = SlidePart(None, None, None, None)
     part_related_by_.side_effect = None if has_notes_slide else KeyError
     expected_value = has_notes_slide
     return slide_part, expected_value
Esempio n. 17
0
 def add_notes_part_fixture(self, package_, NotesSlidePart_,
                            notes_slide_part_, relate_to_):
     slide_part = SlidePart(None, None, None, package_)
     NotesSlidePart_.new.return_value = notes_slide_part_
     return slide_part, NotesSlidePart_, package_, notes_slide_part_