def test_should_create_separate_author_node(self):
     xml_root = extracted_items_to_xml([
         ExtractedItem(Tags.AUTHOR, TEXT_1),
         ExtractedItem(Tags.AUTHOR, TEXT_2)
     ])
     assert xml_root is not None
     assert get_text_content_list(xml_root.findall(
         XmlPaths.AUTHOR)) == [TEXT_1, TEXT_2]
 def test_should_append_to_abstract(self):
     xml_root = extracted_items_to_xml([
         ExtractedItem(Tags.ABSTRACT, TEXT_1),
         ExtractedItem(Tags.ABSTRACT, TEXT_2)
     ])
     assert xml_root is not None
     assert get_text_content(xml_root.find(XmlPaths.ABSTRACT)) == '\n'.join(
         [TEXT_1, TEXT_2])
 def test_should_not_append_to_abstract_after_another_tag_occured(self):
     xml_root = extracted_items_to_xml([
         ExtractedItem(Tags.ABSTRACT, TEXT_1),
         ExtractedItem(Tags.AUTHOR, TEXT_2),
         ExtractedItem(Tags.ABSTRACT, TEXT_3)
     ])
     assert xml_root is not None
     assert get_text_content(xml_root.find(XmlPaths.ABSTRACT)) == '\n'.join(
         [TEXT_1])
def _create_author_extracted_items(given_names, surname):
    return [
        ExtractedItem(Tags.AUTHOR,
                      ' '.join([given_names, surname]),
                      sub_items=[
                          ExtractedItem(SubTags.AUTHOR_GIVEN_NAMES,
                                        given_names),
                          ExtractedItem(SubTags.AUTHOR_SURNAME, surname)
                      ])
    ]
 def test_should_extract_author_surname_and_given_names_from_single_author(
         self):
     xml_root = extracted_items_to_xml([
         ExtractedItem(Tags.AUTHOR,
                       ' '.join([TEXT_1, TEXT_2]),
                       sub_items=[
                           ExtractedItem(SubTags.AUTHOR_GIVEN_NAMES,
                                         TEXT_1),
                           ExtractedItem(SubTags.AUTHOR_SURNAME, TEXT_2)
                       ])
     ])
     assert xml_root is not None
     author = xml_root.find(XmlPaths.AUTHOR)
     assert author is not None
     assert get_text_content(author.find(
         SubXmlPaths.AUTHOR_GIVEN_NAMES)) == TEXT_1
     assert get_text_content(author.find(
         SubXmlPaths.AUTHOR_SURNAME)) == TEXT_2
 def test_should_populate_title(self):
     xml_root = extracted_items_to_xml([ExtractedItem(Tags.TITLE, TEXT_1)])
     assert xml_root is not None
     assert get_text_content(xml_root.find(XmlPaths.TITLE)) == TEXT_1