Пример #1
0
 def it_can_save_itself_to_a_pptx_file(self, temp_pptx_path):
     """Package.save produces a .pptx with plausible contents"""
     # setup ------------------------
     pkg = Package.open()
     # exercise ---------------------
     pkg.save(temp_pptx_path)
     # verify -----------------------
     pkg = Package.open(temp_pptx_path)
     prs = pkg.presentation
     assert prs is not None
     slidemasters = prs.slidemasters
     assert slidemasters is not None
     assert len(slidemasters) == 1
     slidelayouts = slidemasters[0].slidelayouts
     assert slidelayouts is not None
     assert len(slidelayouts) == 11
Пример #2
0
 def it_loads_default_template_when_opened_with_no_path(self):
     prs = Package.open().presentation
     assert prs is not None
     slidemasters = prs.slidemasters
     assert slidemasters is not None
     assert len(slidemasters) == 1
     slidelayouts = slidemasters[0].slidelayouts
     assert slidelayouts is not None
     assert len(slidelayouts) == 11
Пример #3
0
 def test_add_image_returns_matching_image(self):
     pkg = Package.open(images_pptx_path)
     matching_idx = 4
     matching_image = pkg._images[matching_idx]
     # exercise ---------------------
     image = pkg._images.add_image(test_image_path)
     # verify -----------------------
     expected = matching_image
     actual = image
     msg = ("expected images[%d], got images[%d]"
            % (matching_idx, pkg._images.index(image)))
     self.assertEqual(expected, actual, msg)
Пример #4
0
 def test_add_image_adds_new_image(self):
     """ImageCollection.add_image() adds new image on no match"""
     # setup ------------------------
     pkg = Package.open(images_pptx_path)
     expected_partname = '/ppt/media/image8.png'
     expected_len = len(pkg._images) + 1
     expected_sha1 = '79769f1e202add2e963158b532e36c2c0f76a70c'
     # exercise ---------------------
     image = pkg._images.add_image(new_image_path)
     # verify -----------------------
     expected = (expected_partname, expected_len, expected_sha1)
     actual = (image.partname, len(pkg._images), image._sha1)
     msg = "\nExpected: %s\n     Got: %s" % (expected, actual)
     self.assertEqual(expected, actual, msg)
Пример #5
0
 def it_provides_ref_to_package_core_properties_part(self):
     pkg = Package.open()
     assert isinstance(pkg.core_properties, CoreProperties)
Пример #6
0
 def it_provides_ref_to_package_presentation_part(self):
     pkg = Package.open()
     assert isinstance(pkg.presentation, Presentation)
Пример #7
0
 def it_gathers_package_image_parts_on_open(self):
     pkg = Package.open(images_pptx_path)
     assert len(pkg._images) == 7
Пример #8
0
 def test_slidelayouts_correct_length_after_open(self):
     slidemaster = Package.open(test_pptx_path).presentation.slidemasters[0]
     slidelayouts = slidemaster.slidelayouts
     assert len(slidelayouts) == 11
Пример #9
0
 def __init__(self, pkg_file=None):
     super(Presentation, self).__init__()
     self._package = Package.open(pkg_file)
     self._presentation = self._package.presentation