def test_should_create_biblscope_for_page_range_without_from_to(self): result = TeiElementWrapper(get_tei_child_element_for_semantic_content( SemanticPageRange( layout_block=LayoutBlock.for_text('12'), from_page=None, to_page=None ) )) LOGGER.debug('result: %r', etree.tostring(result.element)) assert result.get_xpath_text_content_list( '/tei:biblScope[@unit="page"]' ) == ['12']
def _get_wrapped_figure_tei_element( semantic_figure: SemanticFigure) -> TeiElementWrapper: return TeiElementWrapper( TEI_E( 'root', *FigureTeiElementFactory().get_tei_children_for_semantic_content( semantic_figure, context=DEFAULT_TEI_ELEMENT_FACTORY_CONTEXT)))
def test_should_add_raw_affiliation_without_marker(self): semantic_affiliation_address = SemanticAffiliationAddress([ SemanticInstitution(layout_block=LayoutBlock.for_text('Institution1')) ]) tei_aff = TeiElementWrapper( get_tei_affiliation_for_semantic_affiliation_address_element( semantic_affiliation_address, context=DEFAULT_TEI_ELEMENT_FACTORY_CONTEXT ) ) LOGGER.debug('tei_aff: %r', etree.tostring(tei_aff.element)) assert tei_aff.get_xpath_text_content_list( 'tei:note[@type="raw_affiliation"]' ) == [semantic_affiliation_address.get_text()] assert tei_aff.get_xpath_text_content_list( 'tei:note[@type="raw_affiliation"]/tei:label' ) == []
def _get_wrapped_graphic_tei_element( semantic_graphic: SemanticGraphic ) -> TeiElementWrapper: return TeiElementWrapper(TEI_E( 'root', *GraphicTeiElementFactory().get_tei_children_for_semantic_content( semantic_graphic, context=DEFAULT_TEI_ELEMENT_FACTORY_CONTEXT ) ))
def test_should_add_raw_affiliation_with_formatting(self): semantic_affiliation_address = SemanticAffiliationAddress([ SemanticMarker(layout_block=LayoutBlock.for_text('1')), SemanticInstitution(layout_block=LayoutBlock.merge_blocks([ LayoutBlock.for_text('bold', font=BOLD_FONT_1), LayoutBlock.for_text('italic', font=ITALICS_FONT_1) ])) ]) tei_aff = TeiElementWrapper( get_tei_affiliation_for_semantic_affiliation_address_element( semantic_affiliation_address, context=DEFAULT_TEI_ELEMENT_FACTORY_CONTEXT ) ) LOGGER.debug('tei_aff: %r', etree.tostring(tei_aff.element)) assert tei_aff.get_xpath_text_content_list( 'tei:note[@type="raw_affiliation"]' ) == [semantic_affiliation_address.get_text()] assert tei_aff.get_xpath_text_content_list( 'tei:note[@type="raw_affiliation"]/tei:label' ) == ['1']
def test_should_add_all_fields(self): affiliations_by_marker = { '1': [SemanticAffiliationAddress([ SemanticInstitution(layout_block=LayoutBlock.for_text('Institution1')) ])], '2': [SemanticAffiliationAddress([ SemanticInstitution(layout_block=LayoutBlock.for_text('Institution2')) ])], '3': [SemanticAffiliationAddress([ SemanticInstitution(layout_block=LayoutBlock.for_text('Other')) ])] } semantic_author = SemanticAuthor([ SemanticMarker(layout_block=LayoutBlock.for_text('1')), SemanticMarker(layout_block=LayoutBlock.for_text('2')), SemanticGivenName(layout_block=LayoutBlock.for_text('GivenName1')), SemanticSurname(layout_block=LayoutBlock.for_text('Surname1')) ]) tei_author = TeiElementWrapper( get_tei_author_for_semantic_author_element( semantic_author, context=DEFAULT_TEI_ELEMENT_FACTORY_CONTEXT, affiliations_by_marker=affiliations_by_marker ) ) LOGGER.debug('tei_author: %r', etree.tostring(tei_author.element)) assert tei_author.get_xpath_text_content_list( '//tei:note[@type="marker"]' ) == ['1', '2'] assert tei_author.get_xpath_text_content_list( 'tei:persName/tei:forename' ) == ['GivenName1'] assert tei_author.get_xpath_text_content_list( 'tei:persName/tei:surname' ) == ['Surname1'] assert tei_author.get_xpath_text_content_list( 'tei:affiliation/tei:orgName[@type="institution"]' ) == ['Institution1', 'Institution2']
def get_references(self) -> TeiElementWrapper: return TeiElementWrapper(self.get_references_element())
def get_back_annex(self) -> TeiElementWrapper: return TeiElementWrapper(self.get_back_annex_element())
def get_body(self) -> TeiElementWrapper: return TeiElementWrapper(self.get_body_element())
def test_should_add_all_fields(self): semantic_ref = SemanticReference([ SemanticLabel(layout_block=LayoutBlock.for_text('1.')), SemanticTitle(layout_block=LayoutBlock.for_text('Title 1')), SemanticAuthor([ SemanticGivenName(layout_block=LayoutBlock.for_text('Given Name 1')), SemanticSurname(layout_block=LayoutBlock.for_text('Surname 1')) ]), SemanticRawEditors(layout_block=LayoutBlock.for_text('Editor 1')), SemanticJournal(layout_block=LayoutBlock.for_text('Journal 1')), SemanticVolume(layout_block=LayoutBlock.for_text('Volume 1')), SemanticIssue(layout_block=LayoutBlock.for_text('Issue 1')), SemanticPageRange( layout_block=LayoutBlock.for_text('12-15'), from_page='12', to_page='15' ), SemanticPublisher(layout_block=LayoutBlock.for_text('Publisher 1')), SemanticLocation(layout_block=LayoutBlock.for_text('Location 1')), SemanticExternalUrl( layout_block=LayoutBlock.for_text(WEB_URL_1), value=WEB_URL_1 ), SemanticExternalIdentifier( layout_block=LayoutBlock.for_text(DOI_1), value=DOI_1, external_identifier_type=SemanticExternalIdentifierTypes.DOI ), SemanticDate( layout_block=LayoutBlock.for_text('1991'), year=1991 ), SemanticDate( layout_block=LayoutBlock.for_text('1992'), year=1992 ), ]) tei_ref = TeiElementWrapper(get_tei_reference_element( semantic_ref, context=DEFAULT_TEI_ELEMENT_FACTORY_CONTEXT )) LOGGER.debug('tei_ref: %r', etree.tostring(tei_ref.element)) assert tei_ref.get_xpath_text_content_list( 'tei:note[@type="label"]' ) == ['1.'] assert tei_ref.get_xpath_text_content_list( 'tei:analytic/tei:title[@type="main"]' ) == ['Title 1'] assert tei_ref.get_xpath_text_content_list( 'tei:analytic/tei:author/tei:persName/tei:forename' ) == ['Given Name 1'] assert tei_ref.get_xpath_text_content_list( 'tei:analytic/tei:author/tei:persName/tei:surname' ) == ['Surname 1'] assert tei_ref.get_xpath_text_content_list( 'tei:monogr/tei:editor' ) == ['Editor 1'] assert tei_ref.get_xpath_text_content_list( 'tei:monogr/tei:title[@level="j"]' ) == ['Journal 1'] assert tei_ref.get_xpath_text_content_list( 'tei:monogr/tei:imprint/tei:biblScope[@unit="volume"]' ) == ['Volume 1'] assert tei_ref.get_xpath_text_content_list( 'tei:monogr/tei:imprint/tei:biblScope[@unit="issue"]' ) == ['Issue 1'] assert tei_ref.get_xpath_text_content_list( 'tei:monogr/tei:imprint/tei:biblScope[@unit="page"]/@from' ) == ['12'] assert tei_ref.get_xpath_text_content_list( 'tei:monogr/tei:imprint/tei:biblScope[@unit="page"]/@to' ) == ['15'] assert tei_ref.get_xpath_text_content_list( 'tei:monogr/tei:imprint/tei:publisher' ) == ['Publisher 1'] assert tei_ref.get_xpath_text_content_list( 'tei:monogr/tei:meeting/tei:address/tei:addrLine' ) == ['Location 1'] assert tei_ref.get_xpath_text_content_list( 'tei:analytic/tei:idno[@type="DOI"]' ) == [DOI_1] assert tei_ref.get_xpath_text_content_list( 'tei:ref[@type="url"]' ) == [WEB_URL_1] assert tei_ref.get_xpath_text_content_list( 'tei:monogr/tei:imprint/tei:date[@type="published"]/@when' ) == ['1991'] assert tei_ref.get_xpath_text_content_list( 'tei:monogr/tei:imprint/tei:date[not(@type)]/@when' ) == ['1992']
def test_should_add_all_fields(self): semantic_affiliation_address = SemanticAffiliationAddress([ SemanticMarker(layout_block=LayoutBlock.for_text('1')), SemanticInstitution(layout_block=LayoutBlock.for_text('Institution1')), SemanticDepartment(layout_block=LayoutBlock.for_text('Department1')), SemanticLaboratory(layout_block=LayoutBlock.for_text('Lab1')), SemanticAddressLine(layout_block=LayoutBlock.for_text('AddressLine1')), SemanticPostCode(layout_block=LayoutBlock.for_text('PostCode1')), SemanticPostBox(layout_block=LayoutBlock.for_text('PostBox1')), SemanticRegion(layout_block=LayoutBlock.for_text('Region1')), SemanticSettlement(layout_block=LayoutBlock.for_text('Settlement1')), SemanticCountry(layout_block=LayoutBlock.for_text('Country1')), ]) tei_aff = TeiElementWrapper( get_tei_affiliation_for_semantic_affiliation_address_element( semantic_affiliation_address, context=DEFAULT_TEI_ELEMENT_FACTORY_CONTEXT ) ) LOGGER.debug('tei_aff: %r', etree.tostring(tei_aff.element)) assert tei_aff.get_xpath_text_content_list( 'tei:note[@type="raw_affiliation"]' ) == [semantic_affiliation_address.get_text()] assert tei_aff.get_xpath_text_content_list( 'tei:note[@type="raw_affiliation"]/tei:label' ) == ['1'] assert tei_aff.get_xpath_text_content_list( 'tei:orgName[@type="institution"]' ) == ['Institution1'] assert tei_aff.get_xpath_text_content_list( 'tei:orgName[@type="department"]' ) == ['Department1'] assert tei_aff.get_xpath_text_content_list( 'tei:orgName[@type="laboratory"]' ) == ['Lab1'] assert tei_aff.get_xpath_text_content_list( 'tei:address/tei:addrLine' ) == ['AddressLine1'] assert tei_aff.get_xpath_text_content_list( 'tei:address/tei:postCode' ) == ['PostCode1'] assert tei_aff.get_xpath_text_content_list( 'tei:address/tei:postBox' ) == ['PostBox1'] assert tei_aff.get_xpath_text_content_list( 'tei:address/tei:region' ) == ['Region1'] assert tei_aff.get_xpath_text_content_list( 'tei:address/tei:settlement' ) == ['Settlement1'] assert tei_aff.get_xpath_text_content_list( 'tei:address/tei:country' ) == ['Country1']