Ejemplo n.º 1
0
def test_default_storage():
    store, path = split_storage('foo/bar/baz')
    assert store == 'osfstorage'
    assert path == 'foo/bar/baz'

    store, path = split_storage('/foo/bar/baz')
    assert store == 'osfstorage'
    assert path == 'foo/bar/baz'
Ejemplo n.º 2
0
def test_split_storage():
    store, path = split_storage('osfstorage/foo/bar/baz')
    assert store == 'osfstorage'
    assert path == 'foo/bar/baz'

    store, path = split_storage('github/foo/bar/baz')
    assert store == 'github'
    assert path == 'foo/bar/baz'

    store, path = split_storage('/github/foo/bar/baz')
    assert store == 'github'
    assert path == 'foo/bar/baz'
Ejemplo n.º 3
0
def test_default_storage():
    def simple_getenv(key):
        return None

    with patch('osfclient.cli.os.getenv',
               side_effect=simple_getenv) as mock_getenv:
        store, path = split_storage('foo/bar/baz')
        assert store == 'osfstorage'
        assert path == 'foo/bar/baz'

        store, path = split_storage('/foo/bar/baz')
        assert store == 'osfstorage'
        assert path == 'foo/bar/baz'
Ejemplo n.º 4
0
def test_split_storage():
    store, path = split_storage('osfstorage/foo/bar/baz')
    assert store == 'osfstorage'
    assert path == 'foo/bar/baz'

    store, path = split_storage('github/foo/bar/baz')
    assert store == 'github'
    assert path == 'foo/bar/baz'

    store, path = split_storage('/github/foo/bar/baz')
    assert store == 'github'
    assert path == 'foo/bar/baz'

    store, path = split_storage('figshare/foo/bar/baz')
    assert store == 'figshare'
    assert path == 'foo/bar/baz'

    store, path = split_storage('/figshare/foo/bar/baz')
    assert store == 'figshare'
    assert path == 'foo/bar/baz'

    store, path = split_storage('googledrive/foo/bar/baz')
    assert store == 'googledrive'
    assert path == 'foo/bar/baz'

    store, path = split_storage('/googledrive/foo/bar/baz')
    assert store == 'googledrive'
    assert path == 'foo/bar/baz'
Ejemplo n.º 5
0
def test_custom_split_storage():
    def simple_getenv(key):
        if key == 'KNOWN_PROVIDERS':
            return 'osfstorage,s3,github'
        return None

    with patch('osfclient.cli.os.getenv',
               side_effect=simple_getenv) as mock_getenv:
        store, path = split_storage('osfstorage/foo/bar/baz')
        assert store == 'osfstorage'
        assert path == 'foo/bar/baz'

        store, path = split_storage('github/foo/bar/baz')
        assert store == 'github'
        assert path == 'foo/bar/baz'

        store, path = split_storage('/github/foo/bar/baz')
        assert store == 'github'
        assert path == 'foo/bar/baz'

        store, path = split_storage('figshare/foo/bar/baz')
        assert store == 'osfstorage'
        assert path == 'figshare/foo/bar/baz'

        store, path = split_storage('/figshare/foo/bar/baz')
        assert store == 'osfstorage'
        assert path == 'figshare/foo/bar/baz'

        store, path = split_storage('s3/foo/bar/baz')
        assert store == 's3'
        assert path == 'foo/bar/baz'

        store, path = split_storage('/s3/foo/bar/baz')
        assert store == 's3'
        assert path == 'foo/bar/baz'
Ejemplo n.º 6
0
def checkfile(args):
    storage, remote_path = utils.split_storage(args.remote)
    osf = cli._setup_osf(args)
    project = osf.project(args.project)
    store = project.storage(storage)
    exists = False

    for f in store.files:
        if utils.norm_remote_path(f.path) == remote_path:
            print("%s exists!" % remote_path)
            exists = True
            break
    if not exists:
        print('%s does not exist!' % remote_path)
    return exists
Ejemplo n.º 7
0
def test_split_storage():
    def simple_getenv(key):
        return None

    with patch('osfclient.cli.os.getenv',
               side_effect=simple_getenv) as mock_getenv:
        store, path = split_storage('osfstorage/foo/bar/baz')
        assert store == 'osfstorage'
        assert path == 'foo/bar/baz'

        store, path = split_storage('github/foo/bar/baz')
        assert store == 'github'
        assert path == 'foo/bar/baz'

        store, path = split_storage('/github/foo/bar/baz')
        assert store == 'github'
        assert path == 'foo/bar/baz'

        store, path = split_storage('figshare/foo/bar/baz')
        assert store == 'figshare'
        assert path == 'foo/bar/baz'

        store, path = split_storage('/figshare/foo/bar/baz')
        assert store == 'figshare'
        assert path == 'foo/bar/baz'

        store, path = split_storage('googledrive/foo/bar/baz')
        assert store == 'googledrive'
        assert path == 'foo/bar/baz'

        store, path = split_storage('/googledrive/foo/bar/baz')
        assert store == 'googledrive'
        assert path == 'foo/bar/baz'

        store, path = split_storage('osfstorage/foo/bar/baz/')
        assert store == 'osfstorage'
        assert path == 'foo/bar/baz'

        store, path = split_storage('osfstorage/foo/bar/baz/', normalize=False)
        assert store == 'osfstorage'
        assert path == 'foo/bar/baz/'