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_PartFactory_to_construct_styles_part(self, load_fixture): # fixture ---------------------- styles_part_load_, partname_, blob_, package_, styles_part_ = ( load_fixture) content_type, reltype = CT.WML_STYLES, RT.STYLES # exercise --------------------- part = PartFactory(partname_, content_type, reltype, blob_, package_) # verify ----------------------- styles_part_load_.assert_called_once_with(partname_, content_type, blob_, package_) assert part is styles_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_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_numbering_part( self, load_fixture): # fixture ---------------------- numbering_part_load_, partname_, blob_, package_, numbering_part_ = ( load_fixture) content_type, reltype = CT.WML_NUMBERING, RT.NUMBERING # exercise --------------------- part = PartFactory(partname_, content_type, reltype, blob_, package_) # verify ----------------------- numbering_part_load_.assert_called_once_with(partname_, content_type, blob_, package_) assert part is numbering_part_
def it_is_used_by_PartFactory_to_construct_main_document_part( self, part_load_fixture): # fixture ---------------------- document_part_load_, partname_, blob_, package_, document_part_ = ( part_load_fixture) content_type = CT.WML_DOCUMENT_MAIN reltype = RT.OFFICE_DOCUMENT # exercise --------------------- part = PartFactory(partname_, content_type, reltype, blob_, package_) # verify ----------------------- document_part_load_.assert_called_once_with(partname_, content_type, blob_, package_) assert part is document_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_