示例#1
0
def test_display_list_verb_one(capfd, mock_init, mock_init_sample):
    bibs = bm.load()
    bibs = [bibs[11], bibs[13]]
    bm.display_list(bibs, verb=1)
    captured = capfd.readouterr()
    expected_output = '\x1b[0m\x1b[?7h\x1b[0m\r\n\x1b[0;38;5;33mTitle\x1b[0m: \x1b[0;38;5;130mStudies based on the colors and magnitudes in stellar clusters. VII.\r\n    The distances, distribution in space, and dimensions of 69 globular\r\n    clusters., 1918\x1b[0m\r\n\x1b[0;38;5;33mAuthors\x1b[0m: \x1b[0;38;5;130m{Shapley}, H.\x1b[0m\r\n\x1b[0;38;5;33mADS URL\x1b[0m: \x1b[0;38;5;130mhttp://adsabs.harvard.edu/abs/1918ApJ....48..154S\x1b[0m\r\n\x1b[0;38;5;33mbibcode\x1b[0m: \x1b[0;38;5;130m1918ApJ....48..154S\x1b[0m\r\n\x1b[0;38;5;33mkey\x1b[0m: \x1b[0;38;5;142mShapley1918apjDistanceGlobularClusters\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;130mThe radial velocity of the Andromeda Nebula, 1913\x1b[0m\r\n\x1b[0;38;5;33mAuthors\x1b[0m: \x1b[0;38;5;130m{Slipher}, V. M.\x1b[0m\r\n\x1b[0;38;5;33mADS URL\x1b[0m: \x1b[0;38;5;130mhttps://ui.adsabs.harvard.edu/abs/1913LowOB...2...56S\x1b[0m\r\n\x1b[0;38;5;33mbibcode\x1b[0m: \x1b[0;38;5;130m1913LowOB...2...56S\x1b[0m\r\n\x1b[0;38;5;33mPDF file\x1b[0m: \x1b[0;38;5;248;3mSlipher1913.pdf\x1b[0m\r\n\x1b[0;38;5;33mkey\x1b[0m: \x1b[0;38;5;142mSlipher1913lobAndromedaRarialVelocity\x1b[0m\r\n\x1b[0m'
    assert captured.out == expected_output
示例#2
0
def test_display_list_no_title(capfd, mock_init, mock_init_sample):
    bibs = bm.read_file(text='''@ARTICLE{Slipher1913lobAndromedaRarialVelocity,
       author = {{Slipher}, V.~M.},
         year = 1913,
}''')
    bm.display_list(bibs, verb=0)
    captured = capfd.readouterr()
    expected_output = '\x1b[0m\x1b[?7h\x1b[0m\r\n\x1b[0;38;5;33mTitle\x1b[0m: \x1b[0;38;5;130mNone, 1913\x1b[0m\r\n\x1b[0;38;5;33mAuthors\x1b[0m: \x1b[0;38;5;130m{Slipher}, V. M.\x1b[0m\r\n\x1b[0;38;5;33mkey\x1b[0m: \x1b[0;38;5;142mSlipher1913lobAndromedaRarialVelocity\x1b[0m\r\n\x1b[0m'
    assert captured.out == expected_output
示例#3
0
def test_display_list_no_author(capfd, mock_init, mock_init_sample):
    bibs = bm.read_file(text='''@ARTICLE{Slipher1913lobAndromedaRarialVelocity,
        title = "{The radial velocity of the Andromeda Nebula}",
         year = 1913,
}''')
    bm.display_list(bibs, verb=0)
    captured = capfd.readouterr()
    expected_output = '\x1b[0m\x1b[?7h\x1b[0m\r\n\x1b[0;38;5;33mTitle\x1b[0m: \x1b[0;38;5;130mThe radial velocity of the Andromeda Nebula, 1913\x1b[0m\r\n\x1b[0;38;5;33mkey\x1b[0m: \x1b[0;38;5;142mSlipher1913lobAndromedaRarialVelocity\x1b[0m\r\n\x1b[0m'
    assert captured.out == expected_output
示例#4
0
def test_display_list_verb_zero(capfd, mock_init, mock_init_sample):
    bibs = bm.load()
    bibs = [bibs[11], bibs[13]]
    bm.display_list(bibs, verb=0)
    captured = capfd.readouterr()
    # Trick to see how the screen output looks:
    #print(repr(captured.out))
    #print(captured.out)
    expected_output = '\x1b[0m\x1b[?7h\x1b[0m\r\n\x1b[0;38;5;33mTitle\x1b[0m: \x1b[0;38;5;130mStudies based on the colors and magnitudes in stellar clusters. VII.\r\n    The distances, distribution in space, and dimensions of 69 globular\r\n    clusters., 1918\x1b[0m\r\n\x1b[0;38;5;33mAuthors\x1b[0m: \x1b[0;38;5;130m{Shapley}, H.\x1b[0m\r\n\x1b[0;38;5;33mkey\x1b[0m: \x1b[0;38;5;142mShapley1918apjDistanceGlobularClusters\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;130mThe radial velocity of the Andromeda Nebula, 1913\x1b[0m\r\n\x1b[0;38;5;33mAuthors\x1b[0m: \x1b[0;38;5;130m{Slipher}, V. M.\x1b[0m\r\n\x1b[0;38;5;33mkey\x1b[0m: \x1b[0;38;5;142mSlipher1913lobAndromedaRarialVelocity\x1b[0m\r\n\x1b[0m'
    assert captured.out == expected_output
示例#5
0
def test_display_list_verb_neg(capfd, mock_init, mock_init_sample):
    bibs = bm.load()
    bm.display_list(bibs[0:4], verb=-1)
    captured = capfd.readouterr()
    assert captured.out == (
        '\nKeys:\n'
        'AASteamHendrickson2018aastex62\n'
        'Astropycollab2013aaAstropy\n'
        'BeaulieuEtal2010arxivGJ436b\n'
        'BurbidgeEtal1957rvmpStellarElementSynthesis\n')
示例#6
0
def test_display_list_no_ads(capfd, mock_init, mock_init_sample):
    bibs = bm.read_file(text='''@ARTICLE{Slipher1913lobAndromedaRarialVelocity,
       author = {{Slipher}, V.~M.},
        title = "{The radial velocity of the Andromeda Nebula}",
         year = 1913,
       eprint = {0000.2000},
}''')
    bm.display_list(bibs, verb=1)
    captured = capfd.readouterr()
    expected_output = '\x1b[0m\x1b[?7h\x1b[0m\r\n\x1b[0;38;5;33mTitle\x1b[0m: \x1b[0;38;5;130mThe radial velocity of the Andromeda Nebula, 1913\x1b[0m\r\n\x1b[0;38;5;33mAuthors\x1b[0m: \x1b[0;38;5;130m{Slipher}, V. M.\x1b[0m\r\n\x1b[0;38;5;33mArXiv URL\x1b[0m: \x1b[0;38;5;130mhttp://arxiv.org/abs/0000.2000\x1b[0m\r\n\x1b[0;38;5;33mkey\x1b[0m: \x1b[0;38;5;142mSlipher1913lobAndromedaRarialVelocity\x1b[0m\r\n\x1b[0m'
    assert captured.out == expected_output
示例#7
0
def test_display_list_no_arxiv(capfd, mock_init, mock_init_sample):
    bibs = bm.read_file(text='''@ARTICLE{Slipher1913lobAndromedaRarialVelocity,
       author = {{Slipher}, V.~M.},
        title = "{The radial velocity of the Andromeda Nebula}",
         year = 1913,
       adsurl = {https://ui.adsabs.harvard.edu/abs/1913LowOB...2...56S},
}''')
    bm.display_list(bibs, verb=1)
    captured = capfd.readouterr()
    expected_output = '\x1b[0m\x1b[?7h\x1b[0m\r\n\x1b[0;38;5;33mTitle\x1b[0m: \x1b[0;38;5;130mThe radial velocity of the Andromeda Nebula, 1913\x1b[0m\r\n\x1b[0;38;5;33mAuthors\x1b[0m: \x1b[0;38;5;130m{Slipher}, V. M.\x1b[0m\r\n\x1b[0;38;5;33mADS URL\x1b[0m: \x1b[0;38;5;130mhttps://ui.adsabs.harvard.edu/abs/1913LowOB...2...56S\x1b[0m\r\n\x1b[0;38;5;33mbibcode\x1b[0m: \x1b[0;38;5;130m1913LowOB...2...56S\x1b[0m\r\n\x1b[0;38;5;33mkey\x1b[0m: \x1b[0;38;5;142mSlipher1913lobAndromedaRarialVelocity\x1b[0m\r\n\x1b[0m'
    assert captured.out == expected_output
示例#8
0
def test_display_list_verb_full(capfd, mock_init, mock_init_sample):
    bibs = bm.load()
    bibs = [bibs[11], bibs[13]]
    bm.display_list(bibs, verb=3)
    captured = capfd.readouterr()
    assert captured.out == '\x1b[0m\x1b[?7h\x1b[0;38;5;248;3m\r\n::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\r\n\x1b[0m\x1b[0;38;5;248;3m\x1b[0;38;5;34;1;4m@ARTICLE\x1b[0m{\x1b[0;38;5;142mShapley1918apjDistanceGlobularClusters\x1b[0m,\x1b[0;38;5;250m\r\n   \x1b[0;38;5;33mauthor\x1b[0;38;5;250m \x1b[0m=\x1b[0;38;5;250m \x1b[0;38;5;130m{{Shapley}, H.}\x1b[0m,\x1b[0;38;5;250m\r\n    \x1b[0;38;5;33mtitle\x1b[0;38;5;250m \x1b[0m=\x1b[0;38;5;250m \x1b[0;38;5;130m"{Studies based on the colors and magnitudes in stellar clusters. VII. The distances, distribution in space, and dimensions of 69 globular clusters.}"\x1b[0m,\x1b[0;38;5;250m\r\n  \x1b[0;38;5;33mjournal\x1b[0;38;5;250m \x1b[0m=\x1b[0;38;5;250m \x1b[0;38;5;130m{\\apj}\x1b[0m,\x1b[0;38;5;250m\r\n     \x1b[0;38;5;33myear\x1b[0;38;5;250m \x1b[0m=\x1b[0;38;5;250m \x1b[0;38;5;30m1918\x1b[0m,\x1b[0;38;5;250m\r\n    \x1b[0;38;5;33mmonth\x1b[0;38;5;250m \x1b[0m=\x1b[0;38;5;250m \x1b[0;38;5;124moct\x1b[0m,\x1b[0;38;5;250m\r\n   \x1b[0;38;5;33mvolume\x1b[0;38;5;250m \x1b[0m=\x1b[0;38;5;250m \x1b[0;38;5;30m48\x1b[0m,\x1b[0;38;5;250m\r\n      \x1b[0;38;5;33mdoi\x1b[0;38;5;250m \x1b[0m=\x1b[0;38;5;250m \x1b[0;38;5;130m{10.1086/142423}\x1b[0m,\x1b[0;38;5;250m\r\n   \x1b[0;38;5;33madsurl\x1b[0;38;5;250m \x1b[0m=\x1b[0;38;5;250m \x1b[0;38;5;130m{http://adsabs.harvard.edu/abs/1918ApJ....48..154S}\x1b[0m,\x1b[0;38;5;250m\r\n  \x1b[0;38;5;33madsnote\x1b[0;38;5;250m \x1b[0m=\x1b[0;38;5;250m \x1b[0;38;5;130m{Provided by the SAO/NASA Astrophysics Data System}\x1b[0;38;5;250m\r\n\x1b[0m}\x1b[0;38;5;250m\r\n\x1b[0m\r\n\x1b[0;38;5;248;3mpdf: Slipher1913.pdf\r\n\x1b[0;38;5;34;1;4m@ARTICLE\x1b[0m{\x1b[0;38;5;142mSlipher1913lobAndromedaRarialVelocity\x1b[0m,\x1b[0;38;5;250m\r\n       \x1b[0;38;5;33mauthor\x1b[0;38;5;250m \x1b[0m=\x1b[0;38;5;250m \x1b[0;38;5;130m{{Slipher}, V.~M.}\x1b[0m,\x1b[0;38;5;250m\r\n        \x1b[0;38;5;33mtitle\x1b[0;38;5;250m \x1b[0m=\x1b[0;38;5;250m \x1b[0;38;5;130m"{The radial velocity of the Andromeda Nebula}"\x1b[0m,\x1b[0;38;5;250m\r\n      \x1b[0;38;5;33mjournal\x1b[0;38;5;250m \x1b[0m=\x1b[0;38;5;250m \x1b[0;38;5;130m{Lowell Observatory Bulletin}\x1b[0m,\x1b[0;38;5;250m\r\n     \x1b[0;38;5;33mkeywords\x1b[0;38;5;250m \x1b[0m=\x1b[0;38;5;250m \x1b[0;38;5;130m{GALAXIES: MOTION IN LINE OF SIGHT, ANDROMEDA GALAXY}\x1b[0m,\x1b[0;38;5;250m\r\n         \x1b[0;38;5;33myear\x1b[0;38;5;250m \x1b[0m=\x1b[0;38;5;250m \x1b[0;38;5;30m1913\x1b[0m,\x1b[0;38;5;250m\r\n        \x1b[0;38;5;33mmonth\x1b[0;38;5;250m \x1b[0m=\x1b[0;38;5;250m \x1b[0;38;5;124mJan\x1b[0m,\x1b[0;38;5;250m\r\n       \x1b[0;38;5;33mvolume\x1b[0;38;5;250m \x1b[0m=\x1b[0;38;5;250m \x1b[0;38;5;130m{1}\x1b[0m,\x1b[0;38;5;250m\r\n        \x1b[0;38;5;33mpages\x1b[0;38;5;250m \x1b[0m=\x1b[0;38;5;250m \x1b[0;38;5;130m{56-57}\x1b[0m,\x1b[0;38;5;250m\r\n       \x1b[0;38;5;33madsurl\x1b[0;38;5;250m \x1b[0m=\x1b[0;38;5;250m \x1b[0;38;5;130m{https://ui.adsabs.harvard.edu/abs/1913LowOB...2...56S}\x1b[0m,\x1b[0;38;5;250m\r\n      \x1b[0;38;5;33madsnote\x1b[0;38;5;250m \x1b[0m=\x1b[0;38;5;250m \x1b[0;38;5;130m{Provided by the SAO/NASA Astrophysics Data System}\x1b[0;38;5;250m\r\n\x1b[0m}\x1b[0;38;5;250m\r\n\x1b[0m\r\n\x1b[0m'
示例#9
0
def test_display_list_verb_two(capfd, mock_init, mock_init_sample):
    bibs = bm.load()
    bm.display_list(bibs[3:4], verb=2)
    captured = capfd.readouterr()
    expected_output = '\x1b[0m\x1b[?7h\x1b[0m\r\n\x1b[0;38;5;33mTitle\x1b[0m: \x1b[0;38;5;130mSynthesis of the Elements in Stars, 1957\x1b[0m\r\n\x1b[0;38;5;33mAuthors\x1b[0m: \x1b[0;38;5;130m{Burbidge}, E. Margaret; {Burbidge}, G. R.; {Fowler}, William A.; and\r\n    {Hoyle}, F.\x1b[0m\r\n\x1b[0;38;5;33mADS URL\x1b[0m: \x1b[0;38;5;130mhttps://ui.adsabs.harvard.edu/abs/1957RvMP...29..547B\x1b[0m\r\n\x1b[0;38;5;33mbibcode\x1b[0m: \x1b[0;38;5;130m1957RvMP...29..547B\x1b[0m\r\n\x1b[0;38;5;33mkey\x1b[0m: \x1b[0;38;5;142mBurbidgeEtal1957rvmpStellarElementSynthesis\x1b[0m\r\n\x1b[0m'
    assert captured.out == expected_output