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"""
def test_manager_from_cache(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() am.manager(None) captured = capsys.readouterr() assert captured.out == expected_output2 + 'Showing entries 3--4 out of 26 matches. To show the next set, execute:\nbibm ads-search -n\n'
def test_manager_from_cache(capsys, reqs, ads_entries, mock_init): cm.set('ads_display', '2') captured = capsys.readouterr() am.search.__defaults__ = 0, 4, 'pubdate+desc' querry = 'author:"^fortney, j" year:2000-2018 property:refereed' am.manager(querry) captured = capsys.readouterr() am.manager(None) captured = capsys.readouterr() assert captured.out == f"""
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')
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_manager_cache_trigger_search(capsys, reqs, ads_entries, mock_init): cm.set('ads_display', '2') am.search.__defaults__ = 0, 4, 'pubdate+desc' query = 'author:"^fortney, j" year:2000-2018 property:refereed' am.manager(query) am.manager(None) captured = capsys.readouterr() am.manager(None) captured = capsys.readouterr() expected_output = "\x1b[0m\x1b[?7h\x1b[0m\r\n\x1b[0;38;5;33mTitle\x1b[0m: \x1b[0;38;5;130mDiscovery and Atmospheric Characterization of Giant Planet Kepler-12b:\r\n An Inflated Radius Outlier\x1b[0m\r\n\x1b[0;38;5;33mAuthors\x1b[0m: \x1b[0;38;5;130mFortney, Jonathan J.; et al.\x1b[0m\r\n\x1b[0;38;5;33mADS URL\x1b[0m: \x1b[0;38;5;130mhttps://ui.adsabs.harvard.edu/abs/2011ApJS..197....9F\x1b[0m\r\n\x1b[0;38;5;33mbibcode\x1b[0m: \x1b[0;38;5;142m2011ApJS..197....9F\x1b[0m\r\n\x1b[0m\x1b[0m\x1b[?7h\x1b[0m\r\n\x1b[0;38;5;33mTitle\x1b[0m: \x1b[0;38;5;130mSelf-consistent Model Atmospheres and the Cooling of the Solar System's\r\n Giant Planets\x1b[0m\r\n\x1b[0;38;5;33mAuthors\x1b[0m: \x1b[0;38;5;130mFortney, J. J.; et al.\x1b[0m\r\n\x1b[0;38;5;33mADS URL\x1b[0m: \x1b[0;38;5;130mhttps://ui.adsabs.harvard.edu/abs/2011ApJ...729...32F\x1b[0m\r\n\x1b[0;38;5;33mbibcode\x1b[0m: \x1b[0;38;5;142m2011ApJ...729...32F\x1b[0m\r\n\x1b[0m\nShowing entries 5--6 out of 26 matches. To show the next set, execute:\nbibm ads-search -n\n" assert captured.out == expected_output
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() expected_output = '\x1b[0m\x1b[?7h\x1b[0m\r\n\x1b[0;38;5;33mTitle\x1b[0m: \x1b[0;38;5;130mA Jupiter-mass companion to a solar-type star\x1b[0m\r\n\x1b[0;38;5;33mAuthors\x1b[0m: \x1b[0;38;5;130mMayor, Michel and Queloz, Didier\x1b[0m\r\n\x1b[0;38;5;33mADS URL\x1b[0m: \x1b[0;38;5;130mhttps://ui.adsabs.harvard.edu/abs/1995Natur.378..355M\x1b[0m\r\n\x1b[0;38;5;33mbibcode\x1b[0m: \x1b[0;38;5;142m1995Natur.378..355M\x1b[0m\r\n\x1b[0m\nShowing entries 1--1 out of 1 matches.\n' assert captured.out == expected_output
def test_manager_none(capsys, reqs, ads_entries, mock_init): am.manager(None) captured = capsys.readouterr() assert captured.out == "There are no more entries for this query.\n"