def it_constructs_part_using_default_class_when_no_custom_registered( self, part_args_2_, DefaultPartClass_, part_of_default_type_): partname, content_type, reltype, blob, package = part_args_2_ part = PartFactory(partname, content_type, reltype, blob, package) DefaultPartClass_.load.assert_called_once_with(partname, content_type, blob, package) assert part is part_of_default_type_
def it_is_used_by_loader_to_construct_settings_part( self, load_, package_, settings_part_): partname, blob = 'partname', 'blob' content_type = CT.WML_SETTINGS load_.return_value = settings_part_ part = PartFactory(partname, content_type, None, blob, package_) load_.assert_called_once_with(partname, content_type, blob, package_) assert part is settings_part_
def it_constructs_custom_part_type_for_registered_content_types( self, part_args_, CustomPartClass_, part_of_custom_type_): # fixture ---------------------- partname, content_type, reltype, package, blob = part_args_ # exercise --------------------- PartFactory.part_type_for[content_type] = CustomPartClass_ part = PartFactory(partname, content_type, reltype, blob, package) # verify ----------------------- CustomPartClass_.load.assert_called_once_with(partname, content_type, blob, package) assert part is part_of_custom_type_
def it_is_used_by_PartFactory_to_construct_image_part( self, image_part_load_, partname_, blob_, package_, image_part_): content_type = CT.JPEG reltype = RT.IMAGE image_part_load_.return_value = image_part_ part = PartFactory(partname_, content_type, reltype, blob_, package_) image_part_load_.assert_called_once_with(partname_, content_type, blob_, package_) assert part is image_part_
def it_is_used_by_PartFactory_to_construct_image_part(self, load_fixture): # fixture ---------------------- image_part_load_, partname_, blob_, package_, image_part_ = ( load_fixture) content_type = CT.JPEG reltype = RT.IMAGE # exercise --------------------- part = PartFactory(partname_, content_type, reltype, blob_, package_) # verify ----------------------- image_part_load_.assert_called_once_with(partname_, content_type, blob_, package_) assert part is image_part_
def it_is_used_by_loader_to_construct_endnotes_part( self, package_, EndnotesPart_load_, endnotes_part_): partname = "endnotes.xml" content_type = CT.WML_ENDNOTES reltype = RT.ENDNOTES blob = "<w:endnotes/>" EndnotesPart_load_.return_value = endnotes_part_ part = PartFactory(partname, content_type, reltype, blob, package_) EndnotesPart_load_.assert_called_once_with(partname, content_type, blob, package_) assert part is endnotes_part_
def it_constructs_part_from_selector_if_defined(self, cls_selector_fixture): # fixture ---------------------- (cls_selector_fn_, part_load_params, CustomPartClass_, part_of_custom_type_) = cls_selector_fixture partname, content_type, reltype, blob, package = part_load_params # exercise --------------------- PartFactory.part_class_selector = cls_selector_fn_ part = PartFactory(partname, content_type, reltype, blob, package) # verify ----------------------- cls_selector_fn_.assert_called_once_with(content_type, reltype) CustomPartClass_.load.assert_called_once_with(partname, content_type, blob, package) assert part is part_of_custom_type_
def it_is_used_by_loader_to_construct_header_part(self, package_, HeaderPart_load_, header_part_): partname = "header1.xml" content_type = CT.WML_HEADER reltype = RT.HEADER blob = "<w:hdr/>" HeaderPart_load_.return_value = header_part_ part = PartFactory(partname, content_type, reltype, blob, package_) HeaderPart_load_.assert_called_once_with(partname, content_type, blob, package_) assert part is header_part_
def it_is_used_by_loader_to_construct_footer_part(self, package_, FooterPart_load_, footer_part_): partname = "footer1.xml" content_type = CT.WML_FOOTER reltype = RT.FOOTER blob = "<w:ftr/>" FooterPart_load_.return_value = footer_part_ part = PartFactory(partname, content_type, reltype, blob, package_) FooterPart_load_.assert_called_once_with(partname, content_type, blob, package_) assert part is footer_part_
def it_is_used_by_loader_to_construct_settings_part(self, load_fixture): partname, content_type, blob, package_, settings_part_ = load_fixture part = PartFactory(partname, content_type, None, blob, package_) SettingsPart.load.assert_called_once_with(partname, content_type, blob, package_) assert part is settings_part_