def test_should_create_head_for_child_section_title(self): semantic_heading = SemanticHeading([ SemanticTitle(layout_block=LayoutBlock.for_text('Section Title 1')) ]) tei_head = get_tei_child_element_for_semantic_content(semantic_heading) LOGGER.debug('tei_head: %r', etree.tostring(tei_head)) assert get_text_content(tei_head) == 'Section Title 1' assert not list(tei_head)
def test_should_create_idno_for_unknown_type(self): semantic_external_identifier = SemanticExternalIdentifier( layout_block=LayoutBlock.for_text('Section Title 1'), value='Other1', external_identifier_type=None ) tei_idno = get_tei_child_element_for_semantic_content(semantic_external_identifier) LOGGER.debug('tei_idno: %r', etree.tostring(tei_idno)) assert get_text_content(tei_idno) == semantic_external_identifier.value assert tei_idno.attrib.get('type') is None
def test_should_create_idno_for_doi(self): semantic_external_identifier = SemanticExternalIdentifier( layout_block=LayoutBlock.for_text('Section Title 1'), value=DOI_1, external_identifier_type=SemanticExternalIdentifierTypes.DOI ) tei_idno = get_tei_child_element_for_semantic_content(semantic_external_identifier) LOGGER.debug('tei_idno: %r', etree.tostring(tei_idno)) assert get_text_content(tei_idno) == DOI_1 assert tei_idno.attrib['type'] == semantic_external_identifier.external_identifier_type
def test_should_not_strip_dot_from_label(self): semantic_heading = SemanticHeading([ SemanticLabel(layout_block=LayoutBlock.for_text('1.')), SemanticTitle(layout_block=LayoutBlock.for_text('Section Title 1')) ]) tei_head = get_tei_child_element_for_semantic_content(semantic_heading) LOGGER.debug('tei_head: %r', etree.tostring(tei_head)) assert tei_head.attrib.get('n') == '1.' assert get_text_content(tei_head) == 'Section Title 1' assert not list(tei_head)
def test_should_add_superscript_text(self): block = LayoutBlock.for_tokens([ LayoutToken(TOKEN_1), LayoutToken(TOKEN_2, font=SUPERSCRIPT_FONT_1), LayoutToken(TOKEN_3) ]) node = TEI_E.node(*iter_layout_block_tei_children(block)) assert get_tei_xpath_text_content_list( node, './tei:hi[@rend="superscript"]') == [TOKEN_2] assert get_text_content(node) == ' '.join([TOKEN_1, TOKEN_2, TOKEN_3])
def test_should_add_bold_and_italics_text(self): block = LayoutBlock.for_tokens([ LayoutToken(TOKEN_1), LayoutToken(TOKEN_2, font=BOLD_ITALICS_FONT_1), LayoutToken(TOKEN_3) ]) node = TEI_E.node(*iter_layout_block_tei_children(block)) LOGGER.debug('xml: %r', etree.tostring(node)) assert get_tei_xpath_text_content_list( node, './/tei:hi[@rend="bold"]') == [TOKEN_2] assert get_tei_xpath_text_content_list( node, './/tei:hi[@rend="italic"]') == [TOKEN_2] assert get_text_content(node) == ' '.join([TOKEN_1, TOKEN_2, TOKEN_3])