def test_clone_report_permission_issue(tdir): pdir = Path(tdir) / 'protected' pdir.mkdir() # make it read-only pdir.chmod(0o555) with chpwd(pdir): # first check the premise of the test. If we can write (strangely # mounted/crippled file system, subsequent assumptions are violated # and we can stop probe = Path('probe') try: probe.write_text('should not work') raise SkipTest except PermissionError: # we are indeed in a read-only situation pass res = clone('///', result_xfm=None, return_type='list', on_failure='ignore') assert_status('error', res) assert_result_count( res, 1, status='error', message="could not create work tree dir '%s/%s': Permission denied" % (pdir, get_datasets_topdir()))
def test_clone_report_permission_issue(tdir): pdir = _path_(tdir, 'protected') mkdir(pdir) # make it read-only chmod(pdir, 0o555) with chpwd(pdir): res = clone('///', result_xfm=None, return_type='list', on_failure='ignore') assert_status('error', res) assert_result_count( res, 1, status='error', message="could not create work tree dir '%s/%s': Permission denied" % (pdir, get_datasets_topdir()) )
def test_install_datasets_root(tdir): with chpwd(tdir): ds = install("///") ok_(ds.is_installed()) eq_(ds.path, opj(tdir, get_datasets_topdir())) # do it a second time: result = install("///", result_xfm=None, return_type='list') assert_status('notneeded', result) eq_(YieldDatasets()(result[0]), ds) # and a third time into an existing something, that is not a dataset: with open(opj(tdir, 'sub', 'a_file.txt'), 'w') as f: f.write("something") with assert_raises(IncompleteResultsError) as cme: install("sub", source='///') assert_in("already exists and not empty", str(cme.exception))
def test_clone_datasets_root(tdir): with chpwd(tdir): ds = clone("///", result_xfm='datasets', return_type='item-or-list') ok_(ds.is_installed()) eq_(ds.path, opj(tdir, get_datasets_topdir())) # do it a second time: res = clone("///", on_failure='ignore') assert_message("dataset %s was already cloned from '%s'", res) assert_status('notneeded', res) # and a third time into an existing something, that is not a dataset: with open(opj(tdir, 'sub', 'a_file.txt'), 'w') as f: f.write("something") res = clone('///', path="sub", on_failure='ignore') assert_message( 'target path already exists and not empty, refuse to clone into target path', res) assert_status('error', res)
def test_clone_datasets_root(tdir): tdir = Path(tdir) with chpwd(tdir): ds = clone("///") ok_(ds.is_installed()) eq_(ds.pathobj, tdir / get_datasets_topdir()) # do it a second time: res = clone("///", on_failure='ignore', result_xfm=None, return_type='list') assert_message( "dataset %s was already cloned from '%s'", res) assert_status('notneeded', res) # and a third time into an existing something, that is not a dataset: (tdir / 'sub' / 'a_file.txt').write_text("something") res = clone('///', path="sub", on_failure='ignore') assert_message( 'target path already exists and not empty, refuse to clone into target path', res) assert_status('error', res)
def test_clone_datasets_root(tdir): with chpwd(tdir): ds = clone("///", result_xfm='datasets', return_type='item-or-list') ok_(ds.is_installed()) eq_(ds.path, opj(tdir, get_datasets_topdir())) # do it a second time: res = clone("///", on_failure='ignore') assert_message( "dataset %s was already cloned from '%s'", res) assert_status('notneeded', res) # and a third time into an existing something, that is not a dataset: with open(opj(tdir, 'sub', 'a_file.txt'), 'w') as f: f.write("something") res = clone('///', path="sub", on_failure='ignore') assert_message( 'target path already exists and not empty, refuse to clone into target path', res) assert_status('error', res)
def test_setup(): # just verify that we monkey patched consts correctly from datalad.consts import DATASETS_TOPURL eq_(DATASETS_TOPURL, 'http://datasets-tests.datalad.org/') from datalad.tests.utils import get_datasets_topdir eq_(get_datasets_topdir(), 'datasets-tests.datalad.org')