def test_get_version_existing(mock_init): expected_version = '1.0.0' # Mock pickle DB file with version: with open(u.BM_DATABASE, 'wb') as handle: pickle.dump([], handle, protocol=pickle.HIGHEST_PROTOCOL) pickle.dump(expected_version, handle, protocol=pickle.HIGHEST_PROTOCOL) assert bm.get_version() == expected_version
def test_get_version_filed(tmp_path, mock_init): expected_version = '1.0.0' db = f'{tmp_path}/bm_database.pickle' with open(db, 'wb') as handle: pickle.dump([], handle, protocol=4) pickle.dump(expected_version, handle, protocol=4) assert bm.get_version(db) == expected_version
def test_get_version_no_pickle(mock_init): # Make sure there's no database: with u.ignored(OSError): os.remove(u.BM_DATABASE) assert bm.get_version() == bibm.__version__
def test_get_version_older(mock_init): # Mock pickle DB file without version: with open(u.BM_DATABASE, 'wb') as handle: pickle.dump([], handle, protocol=pickle.HIGHEST_PROTOCOL) assert bm.get_version() == '0.0.0'