Skip to content

Commit

Permalink
BF(TST): do not assume user naiveness - treat any url-like looking pa…
Browse files Browse the repository at this point in the history
…th as a path

clone  help/doc says that PATH must be a path.  Both ssh://X/Y and ssh://X:y
are valid (although I would not recommend them, and 2nd / would be
ignored) paths, so users should be able to clone into them.  Git seems
to perform that way as well:

    $> git clone git://github.com/ReproNim/reproseed https://github.com/ReproNim/reproseed
    Cloning into https://github.com/ReproNim/reproseed...
    remote: Enumerating objects: 44, done.
    remote: Counting objects: 100% (44/44), done.
    remote: Compressing objects: 100% (30/30), done.
    remote: Total 44 (delta 15), reused 35 (delta 11), pack-reused 0
    Receiving objects: 100% (44/44), 8.29 KiB | 8.29 MiB/s, done.
    Resolving deltas: 100% (15/15), done.

although does fails if both URLs match up (what we do too).
  • Loading branch information
yarikoptic committed May 16, 2019
1 parent 98a057e commit f636b04
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions datalad/distribution/tests/test_clone.py
Expand Up @@ -65,11 +65,25 @@
@with_tempfile(mkdir=True)
@with_tempfile(mkdir=True)
def test_invalid_args(path, otherpath, alienpath):
# source == path
assert_raises(ValueError, clone, 'Zoidberg', path='Zoidberg')
# install to an invalid URL
assert_raises(ValueError, clone, 'Zoidberg', path='ssh://mars:Zoidberg')
# install to a remote location
assert_raises(ValueError, clone, 'Zoidberg', path='ssh://mars/Zoidberg')
assert_raises(ValueError, clone, 'ssh://mars/Zoidberg', path='ssh://mars/Zoidberg')

# "invalid URL" is a valid filepath... and since no clone to remote
# is possible - we can just assume that it is the (legit) file path
# which is provided, not a URL. So both below should fail as any
# other clone from a non-existing source and not for the reason of
# "invalid something". Behavior is similar to how Git performs - can
# clone into a URL-like path.

# install to an "invalid URL" path
res = clone('Zoidberg', path='ssh://mars:Zoidberg', on_failure='ignore')
assert_status('error', res)

# install to a "remote location" path
res = clone('Zoidberg', path='ssh://mars/Zoidberg', on_failure='ignore')
assert_status('error', res)

# make fake dataset
ds = create(path)
assert_raises(IncompleteResultsError, ds.clone, '/higherup.', 'Zoidberg')
Expand Down

0 comments on commit f636b04

Please sign in to comment.