Esempio n. 1
0
def test_load_filed(tmp_path, bibs, mock_init):
    my_bibs = [bibs["beaulieu_apj"], bibs["stodden"]]
    bm.save(my_bibs)
    db = f'{tmp_path}/bm_database.pickle'
    shutil.copy(u.BM_DATABASE(), db)
    loaded_bibs = bm.load(db)
    assert loaded_bibs == my_bibs
def test_set_home_merge(tmp_path, bibs, mock_init):
    new_home = f'{tmp_path}/bm'
    os.mkdir(f'{new_home}')
    bib1, bib2 = bibs["beaulieu_apj"], bibs["stodden"]
    bib1.pdf, bib2.pdf = 'file1.pdf', 'file2.pdf'
    bm.save([bib1])
    shutil.copy(u.BM_DATABASE(), f'{new_home}/bm_database.pickle')
    bm.export([bib1], f'{new_home}/bm_bibliography.bib', meta=True)
    bm.export([bib2], f'{new_home}/other.bib', meta=True)
    bm.init(f'{new_home}/other.bib')
    cm.set('home', new_home)
    # Check DBs are merged:
    bibs = bm.load()
    assert len(bibs) == 2
    assert bibs[0].content == bib1.content
    assert bibs[1].content == bib2.content
    # Check both meta exist:
    assert bibs[0].pdf == 'file1.pdf'
    assert bibs[1].pdf == 'file2.pdf'
Esempio n. 3
0
def test_load(bibs, mock_init):
    my_bibs = [bibs["beaulieu_apj"], bibs["stodden"]]
    bm.save(my_bibs)
    loaded_bibs = bm.load()
    assert loaded_bibs == my_bibs
Esempio n. 4
0
def test_save(bibs, mock_init):
    my_bibs = [bibs["beaulieu_apj"]]
    bm.save(my_bibs)
    assert "bm_database.pickle" in os.listdir(u.HOME)