Example #1
0
def test_resolve_pending_paths_no_pending_paths(xdg):
    # set up system
    user = '******'
    given = _init_user_paths(user)
    upf = _user_path_file(user)
    assert os.path.exists(upf)
    # no pending paths to resolve, but let's make sure we get the user paths.
    paths = resolve_pending_paths(user)
    for path, info in paths.items():
        assert path in given
        assert isinstance(info['holding'], float)
Example #2
0
def test_delete(xdg, verify_user):
    user = '******'
    given = _init_user_paths(user)
    fname = os.path.join(ENV['FIXIE_SIMS_DIR'], '0.txt')
    with open(fname, 'w') as f:
        f.write('as you wish')
    # fetch the file
    status, msg = delete('/as', user, '42', timeout=10.0)
    assert status, msg
    assert not os.path.exists(fname)
    paths = resolve_pending_paths(user, timeout=10.0)
    assert '/as' not in paths
Example #3
0
def test_gc(xdg, verify_user):
    user = '******'
    given = _init_user_paths(user)
    for i in range(3):
        fname = os.path.join(ENV['FIXIE_SIMS_DIR'], str(i) + '.h5')
        with open(fname, 'w') as f:
            f.write('as you wish')
    # Garbage collection should remove only 1.h5, since it has a zero holding time
    status, msg = gc(timeout=10.0)
    assert status, msg
    obs = {ENV['FIXIE_SIMS_DIR'] + '/0.h5', ENV['FIXIE_SIMS_DIR'] + '/2.h5'}
    assert obs == set(glob.iglob(ENV['FIXIE_SIMS_DIR'] + '/*.h5'))
    paths = resolve_pending_paths(user, timeout=10.0)
    assert {'/as', '/wish'} == set(paths.keys())
Example #4
0
def test_resolve_pending_paths_all(xdg):
    # set up system
    user = '******'
    given = _init_user_paths(user)
    pps = _init_pending_paths(user)
    upf = _user_path_file(user)
    assert os.path.exists(upf)
    for pp in pps:
        assert os.path.exists(pp['file'])
    # resolve the pending paths we just created.
    paths = resolve_pending_paths(user)
    # make sure that the paths file exists and the pending paths are gone.
    for pp in pps:
        assert not os.path.exists(pp['file'])
    assert os.path.exists(upf)
    # make sure that all keys are present in the paths
    exp_paths = {pp['path'] for pp in pps}
    exp_paths.update(given.keys())
    obs_paths = set(paths.keys())
    assert exp_paths == obs_paths
Example #5
0
def test_resolve_pending_paths_no_user_file(xdg):
    # set up system
    user = '******'
    pps = _init_pending_paths(user)
    for pp in pps:
        assert os.path.exists(pp['file'])
    upf = _user_path_file(user)
    assert not os.path.exists(upf)
    # resolve the pending paths we just created.
    paths = resolve_pending_paths(user)
    # make sure that the paths file exists and the pending paths are gone.
    for pp in pps:
        assert not os.path.exists(pp['file'])
    assert os.path.exists(upf)
    # make sure the paths are well formed
    for path, info in paths.items():
        assert user == info['user']
        assert path == info['path']
        assert 'created' in info
        assert isinstance(info['holding'], float)
Example #6
0
def test_resolve_pending_paths_no_files(xdg):
    obs = resolve_pending_paths('inigo')
    assert {} == obs