コード例 #1
0
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'])
コード例 #2
0
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.add('.')
    ok_clean_git(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'])
コード例 #3
0
def test_file_extraction(path=None):
    skip_if_no_module('libxmp')

    # go into virgin dir to avoid detection of any dataset
    with chpwd(path):
        res = extract_metadata(
            types=['xmp'],
            files=[testpath])
        assert_result_count(res, 1, type='file', status='ok', action='metadata', path=testpath)
        assert_in('xmp', res[0]['metadata'])
コード例 #4
0
def test_file_extraction(path):
    from datalad.tests.utils import SkipTest
    try:
        import libxmp
    except ImportError:
        raise SkipTest

    # go into virgin dir to avoid detection of any dataset
    with chpwd(path):
        res = extract_metadata(
            types=['xmp'],
            files=[testpath])
        assert_result_count(res, 1, type='file', status='ok', action='metadata', path=testpath)
        assert_in('xmp', res[0]['metadata'])
コード例 #5
0
def test_error(path):
    # go into virgin dir to avoid detection of any dataset
    with chpwd(path):
        res = extract_metadata(types=['bogus__'], files=[testpath])
        assert_status('error', res)