Ejemplo n.º 1
0
def test_search_bibcode_multiple(mock_init_sample):
    # Multiple-bibcode querries act with OR logic:
    matches = bm.search(bibcode=["2013A%26A...558A..33A","1957RvMP...29..547B"])
    assert len(matches) == 2
    keys = [m.key for m in matches]
    assert 'Astropycollab2013aaAstropy' in keys
    assert 'BurbidgeEtal1957rvmpStellarElementSynthesis' in keys
Ejemplo n.º 2
0
def test_search_key_multiple(mock_init_sample):
    # Multiple-key querries act with OR logic:
    matches = bm.search(key=["Astropycollab2013aaAstropy",
                             "BurbidgeEtal1957rvmpStellarElementSynthesis"])
    assert len(matches) == 2
    keys = [m.key for m in matches]
    assert 'Astropycollab2013aaAstropy' in keys
    assert 'BurbidgeEtal1957rvmpStellarElementSynthesis' in keys
Ejemplo n.º 3
0
def test_search_title_entry_without_title(mock_init_sample, entries):
    # Multiple-title querries act with AND logic:
    bib = bm.Bib(entries['jones_no_title'])
    bm.merge(new=[bib])
    matches = bm.search(title=['HD 209458b', 'atmospheric circulation'])
    assert len(matches) == 1
    keys = [m.key for m in matches]
    assert 'ShowmanEtal2009apjRadGCM' in keys
Ejemplo n.º 4
0
def test_set_home_and_edit(tmp_path, mock_init, bibs, reqs):
    new_home = f'{tmp_path}/bm'
    cm.set('home', new_home)
    assert cm.get('home') == new_home + '/'
    # Test merge:
    bm.merge(new=[bibs["beaulieu_apj"]], take='new')
    # Test search:
    matches = bm.search(authors="beaulieu")
    assert len(matches) == 1
    assert 'BeaulieuEtal2011apjGJ436bMethane' in matches[0].key
    # Test ADS add:
    am.add_bibtex(['1925PhDT.........1P'], ['Payne1925phdStellarAtmospheres'])
    # Test load:
    current_bibs = bm.load()
    assert len(current_bibs) == 2
    assert 'Payne1925phdStellarAtmospheres' in current_bibs[1].key
    # These files/folders stay:
    assert set(os.listdir(u.HOME)) == set(["config", "examples", "pdf"])
    # These files have been moved/created:
    assert set(os.listdir(str(new_home))) == \
        set(['pdf', 'bm_bibliography.bib', 'bm_database.pickle'])
Ejemplo n.º 5
0
def test_search_bibcode(mock_init_sample):
    matches = bm.search(bibcode="2013A&A...558A..33A")
    assert len(matches) == 1
    keys = [m.key for m in matches]
    assert 'Astropycollab2013aaAstropy' in keys
Ejemplo n.º 6
0
def test_search_year_range(mock_init_sample):
    matches = bm.search(authors="cubillos, p", year=[2013, 2016])
    assert len(matches) == 2
    keys = [m.key for m in matches]
    assert 'CubillosEtal2013apjWASP8b' in keys
    assert 'Cubillos2016phdThesis' in keys
Ejemplo n.º 7
0
def test_search_year_specific(mock_init_sample):
    matches = bm.search(authors="cubillos, p", year=2016)
    assert len(matches) == 1
    keys = [m.key for m in matches]
    assert 'Cubillos2016phdThesis' in keys
Ejemplo n.º 8
0
def test_search_title_multiple(mock_init_sample):
    # Multiple-title querries act with AND logic:
    matches = bm.search(title=['HD 209458b', 'atmospheric circulation'])
    assert len(matches) == 1
    keys = [m.key for m in matches]
    assert 'ShowmanEtal2009apjRadGCM' in keys
Ejemplo n.º 9
0
def test_search_author_year_title(mock_init_sample):
    # Combined-fields querries act with AND logic:
    matches = bm.search(authors="oliphant, t", year=2006, title="numpy")
    assert len(matches) == 1
    keys = [m.key for m in matches]
    assert 'Oliphant2006numpy' in keys
Ejemplo n.º 10
0
def test_search_author_multiple(mock_init_sample):
    # Multiple-author querries act with AND logic:
    matches = bm.search(authors=["oliphant, t", "jones, e"])
    assert len(matches) == 1
    keys = [m.key for m in matches]
    assert 'JonesEtal2001scipy' in keys
Ejemplo n.º 11
0
def test_search_author_first(mock_init_sample):
    matches = bm.search(authors="^virtanen, p")
    assert len(matches) == 1
    keys = [m.key for m in matches]
    assert 'VirtanenEtal2020natmeScipy' in keys
Ejemplo n.º 12
0
def test_search_author_last_initials(mock_init_sample):
    matches = bm.search(authors="oliphant, t")
    assert len(matches) == 2
    keys = [m.key for m in matches]
    assert 'JonesEtal2001scipy' in keys
    assert 'Oliphant2006numpy' in keys
Ejemplo n.º 13
0
def test_search_year_range(mock_init_sample):
    matches = bm.search(authors="granger, b", year=[2007,2018])
    assert len(matches) == 2
    keys = [m.key for m in matches]
    assert 'PerezGranger2007cseIPython' in keys
    assert 'MeurerEtal2017pjcsSYMPY' in keys
Ejemplo n.º 14
0
def test_search_year_specific(mock_init_sample):
    matches = bm.search(authors="granger", year=2007)
    assert len(matches) == 1
    keys = [m.key for m in matches]
    assert 'PerezGranger2007cseIPython' in keys
Ejemplo n.º 15
0
def test_search_bibcode_utf8(mock_init_sample):
    # UTF8 decoding is done at run time, so this works as well:
    matches = bm.search(bibcode="2013A%26A...558A..33A")
    assert len(matches) == 1
    keys = [m.key for m in matches]
    assert 'Astropycollab2013aaAstropy' in keys
Ejemplo n.º 16
0
def test_search_author_first(mock_init_sample):
    matches = bm.search(authors="^oliphant, t")
    assert len(matches) == 1
    keys = [m.key for m in matches]
    assert 'Oliphant2006numpy' in keys
Ejemplo n.º 17
0
def test_search_key(mock_init_sample):
    matches = bm.search(key="BurbidgeEtal1957rvmpStellarElementSynthesis")
    assert len(matches) == 1
    keys = [m.key for m in matches]
    assert 'BurbidgeEtal1957rvmpStellarElementSynthesis' in keys
Ejemplo n.º 18
0
def test_search_author_last_initials(mock_init_sample):
    matches = bm.search(authors="oliphant, t")
    assert len(matches) == 2
    keys = [m.key for m in matches]
    assert 'HarrisEtal2020natNumpy' in keys
    assert 'VirtanenEtal2020natmeScipy' in keys