def test_add_readme(path): ds = Dataset(path).create(force=True) ds.save() ds.aggregate_metadata() ok_clean_git(ds.path) assert_status('ok', ds.add_readme()) # should use default name eq_( open(opj(path, 'README.md')).read(), """\ # Dataset "demo_ds" this is for play ### Authors - Betty - Tom ### License PDDL ## General information This is a DataLad dataset (id: {id}). For more information on DataLad and on how to work with its datasets, see the DataLad documentation at: http://docs.datalad.org """.format( id=ds.id)) # should skip on re-run assert_status('notneeded', ds.add_readme())
def test_ds_extraction(path=None): skip_if_no_module('libxmp') ds = Dataset(path).create() copy(testpath, path) ds.save() assert_repo_status(ds.path) res = extract_metadata( types=['xmp'], dataset=ds, # artificially disable extraction from any file in the dataset files=[]) assert_result_count( res, 1, type='dataset', status='ok', action='metadata', path=path, refds=ds.path) assert_in('xmp', res[0]['metadata']) # now the more useful case: getting everything for xmp from a dataset res = extract_metadata( types=['xmp'], dataset=ds) assert_result_count(res, 2) assert_result_count( res, 1, type='dataset', status='ok', action='metadata', path=path, refds=ds.path) assert_result_count( res, 1, type='file', status='ok', action='metadata', path=opj(path, 'xmp.pdf'), parentds=ds.path) for r in res: assert_in('xmp', r['metadata'])
def test_add_readme(path): ds = Dataset(path).create(force=True) ds.save() ds.aggregate_metadata() ok_clean_git(ds.path) assert_status('ok', ds.add_readme()) # should use default name eq_( open(opj(path, 'README.md')).read(), """\ # Dataset "demo_ds" this is for play ### Authors - Betty - Tom ### License PDDL ## General information This is a DataLad dataset (id: {id}). For more information on DataLad and on how to work with its datasets, see the DataLad documentation at: http://docs.datalad.org """.format(id=ds.id)) # should skip on re-run assert_status('notneeded', ds.add_readme())
def test_ds_extraction(path): from datalad.tests.utils import SkipTest try: import libxmp except ImportError: raise SkipTest ds = Dataset(path).create() copy(testpath, path) ds.save() assert_repo_status(ds.path) res = extract_metadata( types=['xmp'], dataset=ds, # artificially disable extraction from any file in the dataset files=[]) assert_result_count(res, 1, type='dataset', status='ok', action='metadata', path=path, refds=ds.path) assert_in('xmp', res[0]['metadata']) # now the more useful case: getting everthing for xmp from a dataset res = extract_metadata(types=['xmp'], dataset=ds) assert_result_count(res, 2) assert_result_count(res, 1, type='dataset', status='ok', action='metadata', path=path, refds=ds.path) assert_result_count(res, 1, type='file', status='ok', action='metadata', path=opj(path, 'xmp.pdf'), parentds=ds.path) for r in res: assert_in('xmp', r['metadata'])