Exemplo n.º 1
0
def test_delete(save_location, compare_to):
    dat = DataHandler('tests')

    dat.delete(save_location=save_location)

    exists = dat.check_group_exists(location=save_location, create=False)
    assert exists == compare_to
Exemplo n.º 2
0
def test_get_keys():
    dat = DataHandler('tests')

    # location exists
    keys = dat.get_keys(save_location='test_loading')

    # location doesn't exist
    dat.delete(save_location='fake_location')
    with pytest.raises(KeyError):
        keys = dat.get_keys(save_location='fake_location')
Exemplo n.º 3
0
def test_rename(old_save_location, new_save_location, delete_old, compare_to):
    dat = DataHandler('tests')
    # save data to rename / move
    dat.save(data={'float': 3.14},
             save_location=old_save_location,
             overwrite=True)
    # make sure the new entry key is available
    dat.delete(save_location=new_save_location)
    # rename to new key
    dat.rename(old_save_location=old_save_location,
               new_save_location=new_save_location,
               delete_old=delete_old)

    # check if the old location exists
    exists = dat.check_group_exists(location=old_save_location, create=False)
    assert exists == compare_to

    # check if the new location exists
    exists = dat.check_group_exists(location=new_save_location, create=False)
    assert exists is True
Exemplo n.º 4
0
def test_rename_dataset():
    old_save_location = 'test_saving'
    new_save_location = 'test_saving_moved'

    dat = DataHandler('tests')
    # save data to rename / move
    dat.save(data={'float': 3.14},
             save_location=old_save_location,
             overwrite=True)
    # make sure the new entry key is available
    dat.delete(save_location=new_save_location)

    dat.rename(old_save_location=old_save_location + '/int',
               new_save_location=new_save_location + '/int',
               delete_old=False)

    # check if the old location exists
    exists = dat.check_group_exists(location=old_save_location, create=False)
    assert exists is True

    # check if the new location exists
    exists = dat.check_group_exists(location=new_save_location, create=False)
    assert exists is True