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)
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)
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)
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)
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_
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"
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 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"
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
def slide_fixture(self, Slide_, slide_): sld = element("p:sld") slide_part = SlidePart(None, None, sld, None) return slide_part, Slide_, sld, slide_
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_
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
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_