def it_can_construct_from_an_Image_instance(self, from_image_fixture): image_, partname_, ImagePart__init__ = from_image_fixture image_part = ImagePart.from_image(image_, partname_) ImagePart__init__.assert_called_once_with(partname_, image_.content_type, image_.blob, image_) assert isinstance(image_part, ImagePart)
def it_can_construct_from_an_Image_instance(self, from_image_fixture): image_, partname_, ImagePart__init__ = from_image_fixture image_part = ImagePart.from_image(image_, partname_) ImagePart__init__.assert_called_once_with( partname_, image_.content_type, image_.blob, image_ ) assert isinstance(image_part, ImagePart)
def it_can_construct_from_an_Image_instance(self, image_, partname_, _init_): image_part = ImagePart.from_image(image_, partname_) _init_.assert_called_once_with(ANY, partname_, image_.content_type, image_.blob, image_) assert isinstance(image_part, ImagePart)
def _add_image_part(self, image): """ Return an |ImagePart| instance newly created from image and appended to the collection. """ partname = self._next_image_partname(image.ext) image_part = ImagePart.from_image(image, partname) self.append(image_part) return image_part
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
def dimensions_fixture(self, request): image_file_path = test_file('monty-truth.png') image = Image.from_file(image_file_path) expected_cx, expected_cy = 1905000, 2717800 # case 1: image part is loaded by PartFactory w/no Image inst if request.param == 'loaded': partname = PackURI('/word/media/image1.png') content_type = CT.PNG image_part = ImagePart.load(partname, content_type, image.blob, None) # case 2: image part is newly created from image file elif request.param == 'new': image_part = ImagePart.from_image(image, None) return image_part, expected_cx, expected_cy
def dimensions_fixture(self, request): image_file_path = test_file('monty-truth.png') image = Image.from_file(image_file_path) expected_cx, expected_cy = 1905000, 2717800 # case 1: image part is loaded by PartFactory w/no Image inst if request.param == 'loaded': partname = PackURI('/word/media/image1.png') content_type = CT.PNG image_part = ImagePart.load( partname, content_type, image.blob, None ) # case 2: image part is newly created from image file elif request.param == 'new': image_part = ImagePart.from_image(image, None) return image_part, expected_cx, expected_cy