def test_should_convert_multiple_affiliations(self):
   logging.basicConfig(level='DEBUG')
   with patch_grobid_service() as (process_header_names, process_affiliations):
     _ = process_header_names
     process_affiliations.return_value = (
       tei_affiliation(
         department=DEPARTMENT_1,
         institution=INSTITUTION_1
       ) +
       tei_affiliation(
         department=DEPARTMENT_2,
         institution=INSTITUTION_2
       )
     )
     enhancer = GrobidXmlEnhancer(GROBID_URL, start_service=False)
     xml_root = E.article()
     create_xml_text(xml_root, XmlPaths.AUTHOR_AFF, TEXT_1)
     enhanced_xml = enhancer(etree.tostring(xml_root))
     get_logger().info('enhanced_xml: %s', enhanced_xml)
     enhanced_xml_root = etree.parse(BytesIO(enhanced_xml))
     affiliations = enhanced_xml_root.findall(XmlPaths.AUTHOR_AFF)
     assert [
       get_text(x.xpath(DEPARTMENT_XPATH)) for x in affiliations
     ] == [DEPARTMENT_1, DEPARTMENT_2]
     assert [
       get_text(x.xpath(INSTITUTION_XPATH)) for x in affiliations
     ] == [INSTITUTION_1, INSTITUTION_2]
 def test_should_convert_single_author(self):
   logging.basicConfig(level='DEBUG')
   with patch_grobid_service() as (process_header_names, process_affiliations):
     _ = process_affiliations
     process_header_names.return_value = pers_name(FORENAME_1, SURNAME_1)
     enhancer = GrobidXmlEnhancer(GROBID_URL, start_service=False)
     xml_root = E.article()
     create_xml_text(xml_root, XmlPaths.AUTHOR, TEXT_1)
     enhanced_xml = enhancer(etree.tostring(xml_root))
     get_logger().info('enhanced_xml: %s', enhanced_xml)
     enhanced_xml_root = etree.parse(BytesIO(enhanced_xml))
     authors = enhanced_xml_root.findall(XmlPaths.AUTHOR)
     assert [
       (get_child_text(author, 'given-names'), get_child_text(author, 'surname'))
       for author in authors
     ] == [(FORENAME_1, SURNAME_1)]