From f636b04d3bce5b7acce688ec03599cfd74a1877f Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Thu, 16 May 2019 09:09:58 -0400 Subject: [PATCH] BF(TST): do not assume user naiveness - treat any url-like looking path 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). --- datalad/distribution/tests/test_clone.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/datalad/distribution/tests/test_clone.py b/datalad/distribution/tests/test_clone.py index a7bb83656d..d1eb0b4512 100644 --- a/datalad/distribution/tests/test_clone.py +++ b/datalad/distribution/tests/test_clone.py @@ -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')