def _get_parts(self):
     parts = []
     pkg_meta = self._get_pkg_meta()
     for part_name, content_type in pkg_meta:
         blob = self.blob_for(part_name)
         if 'image' in content_type:
             image = Image(blob, None, None, content_type)
             part = ImagePart.from_image(image, PackURI(part_name))
         else:
             part = XmlPart.load(PackURI(part_name), content_type, blob,
                                 None)
         parts.append(part)
     return parts
Exemple #2
0
 def it_knows_the_image_filename(self):
     filename = 'foobar.png'
     image = Image(None, filename, None)
     assert image.filename == filename
Exemple #3
0
 def it_knows_the_horz_and_vert_dpi_of_the_image(self, dpi_fixture):
     image_header_, horz_dpi, vert_dpi = dpi_fixture
     image = Image(None, None, image_header_)
     assert image.horz_dpi == horz_dpi
     assert image.vert_dpi == vert_dpi
Exemple #4
0
 def it_knows_the_image_px_dimensions(self, dimensions_fixture):
     image_header_, px_width, px_height = dimensions_fixture
     image = Image(None, None, image_header_)
     assert image.px_width == px_width
     assert image.px_height == px_height
Exemple #5
0
 def it_knows_the_image_content_type(self, content_type_fixture):
     image_header_, content_type = content_type_fixture
     image = Image(None, None, image_header_)
     assert image.content_type == content_type
Exemple #6
0
 def it_provides_access_to_the_image_blob(self):
     blob = b'foobar'
     image = Image(blob, None, None)
     assert image.blob == blob
Exemple #7
0
 def size_fixture(self, image_header_):
     image_header_.px_width, image_header_.px_height = 150, 75
     image_header_.horz_dpi, image_header_.vert_dpi = 72, 200
     image = Image(None, None, image_header_)
     return image, 1905000, 342900
Exemple #8
0
 def scale_fixture(self, request, width_prop_, height_prop_):
     width, height, scaled_width, scaled_height = request.param
     width_prop_.return_value = Emu(1000)
     height_prop_.return_value = Emu(2000)
     image = Image(None, None, None)
     return image, width, height, (scaled_width, scaled_height)
Exemple #9
0
 def it_knows_the_sha1_of_its_image(self):
     blob = b'fO0Bar'
     image = Image(blob, None, None)
     assert image.sha1 == '4921e7002ddfba690a937d54bda226a7b8bdeb68'
Exemple #10
0
 def it_knows_the_image_filename_extension(self):
     image = Image(None, 'foobar.png', None)
     assert image.ext == 'png'