Beispiel #1
0
def test_descriptors():
    results = read("MH  - Male\nMH  - *Humans\nMH  - Head/*Sub\n\n")

    assert len(results) == 1
    assert 'descriptors' in results[0]
    assert results[0]['descriptors'] == [{'descriptor': 'Male', 'major': False},
                                         {'descriptor': 'Humans', 'major': True},
                                         {'descriptor': 'Head', 'qualifier': 'Sub', 'major': True}]
Beispiel #2
0
def test_ref_dates():
    results = read('LR  - 20200604\nDEP - 20191231\n\n')
    assert len(results) == 1
    assert 'last_revision_date' in results[0]
    assert results[0]['last_revision_date'] == datetime(2020, 6, 4)

    assert 'electronic_publication_date' in results[0]
    assert results[0]['electronic_publication_date'] == datetime(2019, 12, 31)
Beispiel #3
0
def test_read_authors():
    results = read("FAU - Karl J Holub\nAU  - KJ Holub\nAD  - Nested Knowledge Inc., Minneapolis, MN\nAD  - Duluth, MN\nFAU - Other Author\n\n")

    assert len(results) == 1
    assert 'authors' in results[0]
    assert len(results[0]['authors']) == 2
    assert {'author': 'Other Author'} in results[0]['authors']
    assert {'author': 'Karl J Holub',
            'author_abbreviated': 'KJ Holub',
            'affiliations': ['Nested Knowledge Inc., Minneapolis, MN',
                             'Duluth, MN']} in results[0]['authors']
Beispiel #4
0
def test_pmid():
    results = read("PMID- 12345\n\n")

    assert len(results) == 1
    assert 'pubmed_id' in results[0]
    assert results[0]['pubmed_id'] == 12345
Beispiel #5
0
def test_read_multiple_complex_refs():
    results = read('PMID- 1\nTI  - Nice Title\nFAU - Karl\nAD  - Minnesota\n\nPMID- 2\nTI  - Another \n      Continuation\nPT  - Journal Article\nOT  - fun\nOT  - stuff\n\n')

    assert len(results) == 2
    assert set(ref['pubmed_id'] for ref in results) == {1, 2}
    assert set(ref['title'] for ref in results) == {'Nice Title', 'Another Continuation'}
Beispiel #6
0
def test_read_multiple_simple_refs():
    results = read('PMID- 1\n\nPMID- 2\n\nPMID- 3\n\n')

    assert len(results) == 3
    assert all(['pubmed_id' in ref for ref in results])
    assert set(ref['pubmed_id'] for ref in results) == {1, 2, 3}
Beispiel #7
0
def test_read_full_single_ref():
    results = read(single_ref)

    assert len(results) == 1

    result = results[0]
    target_study_attributes = {
        'pubmed_id': 28754806,
        'citation_owner': 'NLM',
        'electronic_issn': '1759-8486',
        'linking_issn': '1759-8478',
        'journal_volume': '10',
        'journal_issue': '4',
        'publication_date': '2018 Apr',
        'title': 'Impact of balloon guide catheter on technical and clinical outcomes: a systematic review and meta-analysis.',
        'pages': '335-339',
        'doi': '10.1136/neurintsurg-2017-013179',
        'abstract': 'BACKGROUND AND PURPOSE: Flow arrest with balloon guide catheters (BGCs) is becoming increasingly recognized as critical to optimizing patient outcomes for mechanical thrombectomy. And I could go on...',
        'copyright': '© Article author(s) (or their employer(s) unless otherwise stated in the text of the article) 2018. All rights reserved. No commercial use is permitted unless otherwise expressly granted.',
        'language': 'eng',
        'electronic_publication_date': datetime(2017, 7, 28),
        'place_of_publication': 'England',
        'journal_abbreviated': 'J Neurointerv Surg',
        'journal': 'Journal of neurointerventional surgery',
        'nlm_journal_id': '101517079',
        'publication_status': 'ppublish',
        'entrez_time': datetime(2017, 7, 30, 6),
        'medline_time': datetime(2018, 8, 1, 6),
        'received_time': datetime(2017, 5, 5)
    }

    for att, value in target_study_attributes.items():
        assert att in result
        assert result[att] == value

    target_authors = [
        {
            "author": "Brinjikji, Waleed",
            "author_abbreviated": "Brinjikji W",
            "affiliations": [
                "Department of Radiology, Mayo Clinic, Rochester, Minnesota, USA.",
                "Department of Neurosurgery, Mayo Clinic, Rochester, Minnesota, USA.",
                "Department of Neuroradiology, Toronto Western Hospital, University of Toronto, Toronto, Ontario, Canada."
            ],
            'first_name': 'Waleed',
            'last_name': 'Brinjikji',
        },
        {
            "author": "Pereira, Vitor M",
            "author_abbreviated": "Pereira VM",
            "affiliations": [
                "Department of Neuroradiology, Toronto Western Hospital, University of Toronto, Toronto, Ontario, Canada."
            ],
            'first_name': 'Vitor M',
            'last_name': 'Pereira',
        },
        {
            "author": "Kallmes, David F",
            "author_abbreviated": "Kallmes DF",
            "affiliations": [
                "Department of Radiology, Mayo Clinic, Rochester, Minnesota, USA.",
                "Department of Neurosurgery, Mayo Clinic, Rochester, Minnesota, USA."
            ],
            'first_name': 'David F',
            'last_name': 'Kallmes'
        }
    ]

    for auth in target_authors:
        assert auth in result['authors']

    target_keywords = ['mechanical thrombectomy', 'stroke']
    for key in target_keywords:
        assert key in result['keywords']

    target_publication_types = ['Journal Article', 'Meta-Analysis', 'Systematic Review', 'Review']
    for pt in target_publication_types:
        assert pt in result['publication_types']

    target_mesh = [
        {'descriptor': 'Aged',  'major':  False},
        {'descriptor': 'Brain Ischemia', 'qualifier': 'diagnostic imaging', 'major': False},
        {'descriptor': 'Brain Ischemia', 'qualifier': 'surgery', 'major': True},
        {'descriptor': 'Clinical Trials as Topic', 'qualifier': 'methods', 'major': False},

    ]
    for d in target_mesh:
        assert d in result['descriptors']
Beispiel #8
0
def test_grants():
    results = read('GR  - NIH 1234\nGR  - NLM RO1\n\n')
    assert len(results) == 1
    assert 'grants' in results[0]
    assert set(results[0]['grants']) == {'NIH 1234', 'NLM RO1'}
Beispiel #9
0
def test_read_keywords():
    results = read("OT  - thing1\nOT  - thing2\n\n")

    assert len(results) == 1
    assert 'keywords' in results[0]
    assert set(results[0]['keywords']) == {'thing1', 'thing2'}
Beispiel #10
0
def test_publication_type():
    results = read("PT  - Journal Article\nPT  - Meta-Analysis\nPT  - Systematic Review\n\n")

    assert len(results) == 1
    assert 'publication_types' in results[0]
    assert set(results[0]['publication_types']) == {'Journal Article', 'Meta-Analysis', 'Systematic Review'}
Beispiel #11
0
def test_read_single():
    file_results = read_file('tests/resources/single.nbib')
    str_results = read(single_ref)

    assert file_results == str_results