summaryrefslogtreecommitdiffstats
path: root/python/tests/import_pubmed.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-05-21 11:03:31 -0700
committerBryan Newbold <bnewbold@robocracy.org>2019-05-21 11:41:29 -0700
commit0ec3fc58b4394102ffaaf385e6048a6412a9c9b7 (patch)
treec83c9266f8fe5599ba95a95d47430b1b96fce247 /python/tests/import_pubmed.py
parent1829eee6e01a4d21604ce1ec6c7a5230467b4b63 (diff)
downloadfatcat-0ec3fc58b4394102ffaaf385e6048a6412a9c9b7.tar.gz
fatcat-0ec3fc58b4394102ffaaf385e6048a6412a9c9b7.zip
updates to pubmed importer
Diffstat (limited to 'python/tests/import_pubmed.py')
-rw-r--r--python/tests/import_pubmed.py49
1 files changed, 45 insertions, 4 deletions
diff --git a/python/tests/import_pubmed.py b/python/tests/import_pubmed.py
index 05a77599..0185c8c4 100644
--- a/python/tests/import_pubmed.py
+++ b/python/tests/import_pubmed.py
@@ -9,12 +9,12 @@ from bs4 import BeautifulSoup
@pytest.fixture(scope="function")
def pubmed_importer(api):
with open('tests/files/ISSN-to-ISSN-L.snip.txt', 'r') as issn_file:
- yield PubmedImporter(api, issn_file, extid_map_file='tests/files/example_map.sqlite3', bezerk_mode=True)
+ yield PubmedImporter(api, issn_file, extid_map_file='tests/files/example_map.sqlite3', bezerk_mode=True, lookup_refs=True)
@pytest.fixture(scope="function")
def pubmed_importer_existing(api):
with open('tests/files/ISSN-to-ISSN-L.snip.txt', 'r') as issn_file:
- yield PubmedImporter(api, issn_file, extid_map_file='tests/files/example_map.sqlite3', bezerk_mode=False)
+ yield PubmedImporter(api, issn_file, extid_map_file='tests/files/example_map.sqlite3', bezerk_mode=False, lookup_refs=True)
def test_pubmed_importer(pubmed_importer):
last_index = pubmed_importer.api.get_changelog(limit=1)[0].index
@@ -73,8 +73,49 @@ def test_pubmed_xml_parse(pubmed_importer):
assert r1.contribs[0].surname == "Blume"
print(r1.extra)
- # TODO: assert r1.extra['pubmed']['mesh_topics'] == ['Accounting', 'Economics, Hospital', 'Hospital Administration']
assert r1.extra['pubmed']['pub_types'] == ['Journal Article']
assert not r1.refs
- # XXX: r2 tests
+ assert r2.title == "Synthesis and Antibacterial Activity of Metal(loid) Nanostructures by Environmental Multi-Metal(loid) Resistant Bacteria and Metal(loid)-Reducing Flavoproteins"
+ assert r2.subtitle == None
+ assert r2.original_title == None
+ assert r2.publisher == None
+ assert r2.release_type == "article-journal"
+ assert r2.release_stage == "published"
+ assert r2.license_slug == None
+ assert r2.ext_ids.doi == "10.3389/fmicb.2018.00959"
+ assert r2.ext_ids.pmid == "29869640"
+ assert r2.ext_ids.pmcid == "PMC5962736"
+ assert r2.language == "en"
+ assert r2.volume == "9"
+ assert r2.issue == None
+ assert r2.pages == "959"
+ assert str(r2.release_date) == "2018-05-15"
+ assert r2.release_year == 2018
+ # matched by ISSN, so shouldn't be in there?
+ #assert extra['container_name'] == "Frontiers in microbiology"
+
+ assert len(r2.contribs) > 3
+ assert r2.contribs[0].raw_name == "Maximiliano Figueroa"
+ assert r2.contribs[0].given_name == "Maximiliano"
+ assert r2.contribs[0].surname == "Figueroa"
+ assert r2.contribs[0].raw_affiliation == "Laboratorio Microbiología Molecular, Departamento de Biología, Facultad de Química y Biología, Universidad de Santiago de Chile, Santiago, Chile."
+ assert r2.contribs[4].surname == "Muñoz-Villagrán"
+ assert r2.contribs[7].surname == "Latorre"
+ assert r2.contribs[7].raw_affiliation == "Mathomics, Centro de Modelamiento Matemático, Universidad de Chile, Beauchef, Santiago, Chile."
+ assert r2.contribs[7].extra['more_affiliations'] == [
+ "Fondap-Center of Genome Regulation, Facultad de Ciencias, Universidad de Chile, Santiago, Chile.",
+ "Laboratorio de Bioinformática y Expresión Génica, INTA, Universidad de Chile, Santiago, Chile.",
+ "Instituto de Ciencias de la Ingeniería, Universidad de O'Higgins, Rancagua, Chile.",
+ ]
+ assert r2.contribs[-1].raw_name == "Felipe Arenas"
+
+ assert r2.abstracts[0].content.startswith("Microbes are suitable candidates to recover and decontaminate different environments from soluble metal ions, either via reduction")
+ assert r2.abstracts[0].lang == "en"
+
+ print(r2.extra)
+ assert r2.extra['pubmed']['pub_types'] == ['Journal Article']
+
+ assert r2.refs[0].extra['unstructured'] == "Microbiology. 2009 Jun;155(Pt 6):1840-6"
+ assert r2.refs[0].extra['pmid'] == "19383690"
+