def test_set_abstract_jats_abstract_format(self):
     """test the abstract using jats abstract format set to true"""
     doi = "10.7554/eLife.00666"
     title = "Test article"
     article = Article(doi, title)
     article.abstract = self.abstract
     article.abstract_xml = self.abstract_xml
     expected_contains = (
         '<jats:abstract xmlns:xlink="http://www.w3.org/1999/xlink">'
         '<jats:p xmlns:xlink="http://www.w3.org/1999/xlink">'
         "<jats:bold><jats:italic><jats:underline><jats:sub><jats:sup>"
         "An abstract. "
         '<jats:ext-link ext-link-type="uri" xlink:href="http://dx.doi.org/10.1601/nm.3602">'
         "Desulfocapsa sulfexigens</jats:ext-link>."
         "</jats:sup></jats:sub></jats:underline></jats:italic></jats:bold> "
         '<jats:xref ref-type="bibr">Stock and Wise (1990)</jats:xref>.'
         "</jats:p></jats:abstract>"
     )
     # generate
     raw_config_object = raw_config("elife")
     jats_abstract = raw_config_object.get("jats_abstract")
     raw_config_object["jats_abstract"] = "true"
     crossref_config = parse_raw_config(raw_config_object)
     crossref_object = generate.CrossrefXML([article], crossref_config, None, True)
     crossref_xml_string = crossref_object.output_xml()
     # test assertion
     self.assertTrue(expected_contains in crossref_xml_string)
     # now set the config back to normal
     raw_config_object["jats_abstract"] = jats_abstract
 def test_component_subtitle_with_face_markup(self):
     """build an article object and component, generate Crossref XML"""
     doi = "10.7554/eLife.00666"
     title = "Test article"
     article = Article(doi, title)
     component = Component()
     component.title = "A component"
     component.subtitle = (
         "A <sc>STRANGE</sc> <italic>subtitle</italic>, " +
         "and this tag is <not_allowed>!</not_allowed>")
     expected_subtitle = (
         "A <sc>STRANGE</sc> <i>subtitle</i>, and this tag " +
         "is &lt;not_allowed&gt;!&lt;/not_allowed&gt;")
     article.component_list = [component]
     # load a config and override the value
     raw_config_object = raw_config("elife")
     face_markup = raw_config_object.get("face_markup")
     raw_config_object["face_markup"] = "true"
     crossref_config = parse_raw_config(raw_config_object)
     # generate the crossrefXML
     c_xml = generate.CrossrefXML([article], crossref_config, None, True)
     crossref_xml_string = c_xml.output_xml()
     self.assertIsNotNone(crossref_xml_string)
     # A quick test just look for the expected string to test for tags and escape characters
     self.assertTrue(expected_subtitle in crossref_xml_string)
     # now set the config back to normal
     raw_config_object["face_markup"] = face_markup
 def test_parse_do_no_pass_pub_date(self):
     """
     For test coverage build a crossrefXML object without passing in a pub_date
     """
     article_xml_file = "elife_poa_e02725.xml"
     file_path = TEST_DATA_PATH + article_xml_file
     articles = generate.build_articles_for_crossref([file_path])
     crossref_config = create_crossref_config("elife")
     crossref_object = generate.CrossrefXML(articles, crossref_config, None,
                                            True)
     self.assertIsNotNone(crossref_object.pub_date)
     self.assertIsNotNone(crossref_object.generated)
     self.assertIsNotNone(
         [tag for tag in crossref_object.root.iter() if tag is Comment])
     self.assertIsNotNone(crossref_object.output_xml())
 def test_generate_jats_abstract_face_markup(self):
     """
     For coverage test JATS and inline output by overriding the config
     """
     article_xml_file = "elife-16988-v1.xml"
     file_path = TEST_DATA_PATH + article_xml_file
     articles = generate.build_articles_for_crossref([file_path])
     crossref_config = create_crossref_config("elife")
     # override config values
     crossref_config["jats_abstract"] = True
     crossref_config["face_markup"] = True
     # create the Crossref XML
     crossref_object = generate.CrossrefXML(articles, crossref_config, None,
                                            True)
     # Check for some tags we expect to find in the output
     self.assertTrue("<jats:italic>" in crossref_object.output_xml())
     self.assertTrue("</b>" in crossref_object.output_xml())
 def test_set_titles_face_markup_format(self):
     """test the title using face markup set to true"""
     doi = "10.7554/eLife.00666"
     article = Article(doi, self.title)
     expected_contains = ("<titles><title><b>Test article</b> for"
                          " Desulfocapsa sulfexigens</title></titles>")
     # generate
     raw_config_object = raw_config("elife")
     face_markup = raw_config_object.get("face_markup")
     raw_config_object["face_markup"] = "true"
     crossref_config = parse_raw_config(raw_config_object)
     crossref_object = generate.CrossrefXML([article], crossref_config,
                                            None, True)
     crossref_xml_string = crossref_object.output_xml()
     # test assertion
     self.assertTrue(expected_contains in crossref_xml_string)
     # now set the config back to normal
     raw_config_object["face_markup"] = face_markup
 def test_ref_list_citation_elocation_id(self):
     """for test coverage for schema where elocation_id goes into first_page element"""
     # load a config and override the value
     raw_config_object = raw_config("elife")
     original_schema_version = raw_config_object.get(
         "crossref_schema_version")
     raw_config_object["crossref_schema_version"] = "4.4.0"
     crossref_config = parse_raw_config(raw_config_object)
     doi = "10.7554/eLife.00666"
     title = "Test article"
     article = Article(doi, title)
     citation = Citation()
     citation.elocation_id = "e00003"
     article.ref_list = [citation]
     c_xml = generate.CrossrefXML([article], crossref_config, None, True)
     crossref_xml_string = c_xml.output_xml()
     self.assertTrue(
         "<first_page>e00003</first_page>" in crossref_xml_string)
     # now set the config back to normal
     raw_config_object["crossref_schema_version"] = original_schema_version
 def generate_crossref_schema_version(self, crossref_schema_version,
                                      expected_snippet):
     """Test non-default crossref schema version"""
     # build an article object and component, generate Crossref XML
     doi = "10.7554/eLife.00666"
     title = "Test article"
     article = Article(doi, title)
     # load a config and override the value
     raw_config_object = raw_config("elife")
     original_schema_version = raw_config_object.get(
         "crossref_schema_version")
     raw_config_object["crossref_schema_version"] = crossref_schema_version
     crossref_config = parse_raw_config(raw_config_object)
     # generate the crossrefXML
     c_xml = generate.CrossrefXML([article], crossref_config, None, True)
     crossref_xml_string = c_xml.output_xml()
     self.assertIsNotNone(crossref_xml_string)
     # A quick test just look for a string value to test
     self.assertTrue(expected_snippet in crossref_xml_string)
     # now set the config back to normal
     raw_config_object["crossref_schema_version"] = original_schema_version