Beispiel #1
0
def test_manager_query_caching(capsys, reqs, ads_entries, mock_init):
    cm.set('ads_display', '2')
    captured = capsys.readouterr()
    am.search.__defaults__ = 0, 4, 'pubdate+desc'
    query = 'author:"^fortney, j" year:2000-2018 property:refereed'
    am.manager(query)
    captured = capsys.readouterr()
    assert os.path.exists(u.BM_CACHE())
    assert captured.out == f"""
Beispiel #2
0
def test_manager_query_caching(capsys, reqs, ads_entries, mock_init):
    cm.set('ads_display', '2')
    captured = capsys.readouterr()
    am.search.__defaults__ = 0, 4, 'pubdate+desc'
    query = 'author:"^fortney, j" year:2000-2018 property:refereed'
    am.manager(query)
    captured = capsys.readouterr()
    assert os.path.exists(u.BM_CACHE())
    assert captured.out == (
        expected_output1 +
        'Showing entries 1--2 out of 26 matches.  To show the next set, '
        'execute:\nbibm ads-search -n\n')
Beispiel #3
0
def test_manager_query_no_caching(capsys, reqs, ads_entries, mock_init):
    query = 'author:"^mayor" year:1995 property:refereed'
    am.manager(query)
    captured = capsys.readouterr()
    assert captured.out == f"""
Title: A Jupiter-mass companion to a solar-type star
Authors: Mayor, Michel and Queloz, Didier
adsurl:  https://ui.adsabs.harvard.edu/abs/1995Natur.378..355M
{u.BOLD}bibcode{u.END}: 1995Natur.378..355M

Showing entries 1--1 out of 1 matches.\n"""
    assert not os.path.exists(u.BM_CACHE())
def test_set_home_success(capsys, tmp_path, mock_init_sample):
    new_home = f'{tmp_path}/bm'
    cm.set('home', new_home)
    assert cm.get('home') == new_home + '/'
    # 'constants' now point to new home:
    assert u.BM_DATABASE() == f'{new_home}/bm_database.pickle'
    assert u.BM_BIBFILE() == f'{new_home}/bm_bibliography.bib'
    assert u.BM_TMP_BIB() == f'{new_home}/tmp_bibliography.bib'
    assert u.BM_CACHE() == f'{new_home}/cached_ads_query.pickle'
    assert u.BM_HISTORY_SEARCH() == f'{new_home}/history_search'
    assert u.BM_HISTORY_ADS() == f'{new_home}/history_ads_search'
    assert u.BM_PDF() == f'{new_home}/pdf/'
    captured = capsys.readouterr()
    assert captured.out == f'home updated to: {new_home}/.\n'
    # 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'])