def __loaded_slidelayout(self, prs_slidemaster=None):
     """
     Return _SlideLayout instance loaded using mocks. *prs_slidemaster* is
     an already-loaded model-side _SlideMaster instance (or mock, as
     appropriate to calling test).
     """
     # partname for related slideMaster
     sldmaster_partname = '/ppt/slideMasters/slideMaster1.xml'
     # path to test slideLayout XML
     slidelayout_path = absjoin(test_file_dir, 'slideLayout1.xml')
     # model-side slideMaster part
     if prs_slidemaster is None:
         prs_slidemaster = Mock(spec=_SlideMaster)
     # a part dict containing the already-loaded model-side slideMaster
     loaded_part_dict = {sldmaster_partname: prs_slidemaster}
     # a slideMaster package part for rel target
     pkg_slidemaster_part = Mock(spec=pptx.packaging.Part)
     pkg_slidemaster_part.partname = sldmaster_partname
     # a package-side relationship from slideLayout to its slideMaster
     rel = Mock(name='pptx.packaging._Relationship')
     rel.rId = 'rId1'
     rel.reltype = RT_SLIDE_MASTER
     rel.target = pkg_slidemaster_part
     # the slideLayout package part to send to _load()
     pkg_slidelayout_part = Mock(spec=pptx.packaging.Part)
     pkg_slidelayout_part.relationships = [rel]
     with open(slidelayout_path, 'rb') as f:
         pkg_slidelayout_part.blob = f.read()
     # _load and return
     slidelayout = _SlideLayout()
     return slidelayout._load(pkg_slidelayout_part, loaded_part_dict)
 def test_add_slide_sets_partname(self):
     """_SlideCollection.add_slide() sets partname of new slide"""
     # setup ------------------------
     prs = Presentation()
     slides = prs.slides
     slidelayout = _SlideLayout()
     slidelayout._shapes = []
     # exercise ---------------------
     slide = slides.add_slide(slidelayout)
     # verify -----------------------
     expected = '/ppt/slides/slide1.xml'
     actual = slide.partname
     msg = "expected partname '%s', got '%s'" % (expected, actual)
     self.assertEqual(expected, actual, msg)
 def test_construction_adds_slide_layout_relationship(self):
     """_Slide(slidelayout) adds relationship slide->slidelayout"""
     # setup ------------------------
     slidelayout = _SlideLayout()
     slidelayout._shapes = _sldLayout1_shapes()
     # exercise ---------------------
     slide = _Slide(slidelayout)
     # verify length ---------------
     expected = 1
     actual = len(slide._relationships)
     msg = ("expected len(slide._relationships) of %d, got %d"
            % (expected, actual))
     self.assertEqual(expected, actual, msg)
     # verify values ---------------
     rel = slide._relationships[0]
     expected = ('rId1', RT_SLIDE_LAYOUT, slidelayout)
     actual = (rel._rId, rel._reltype, rel._target)
     msg = "expected relationship\n%s\ngot\n%s" % (expected, actual)
     self.assertEqual(expected, actual, msg)
 def test_add_slide_adds_slide_layout_relationship(self):
     """_SlideCollection.add_slide() adds relationship prs->slide"""
     # setup ------------------------
     prs = Presentation()
     slides = prs.slides
     slidelayout = _SlideLayout()
     slidelayout._shapes = []
     # exercise ---------------------
     slide = slides.add_slide(slidelayout)
     # verify length ---------------
     expected = 1
     actual = len(prs._relationships)
     msg = ("expected len(prs._relationships) of %d, got %d"
            % (expected, actual))
     self.assertEqual(expected, actual, msg)
     # verify values ---------------
     rel = prs._relationships[0]
     expected = ('rId1', RT_SLIDE, slide)
     actual = (rel._rId, rel._reltype, rel._target)
     msg = ("expected relationship 1:, got 2:\n1: %s\n2: %s"
            % (expected, actual))
     self.assertEqual(expected, actual, msg)
 def setUp(self):
     self.slidelayout = _SlideLayout()