コード例 #1
0
def test_query_empty(path):
    with chpwd(path), assert_raises(ValueError):
        meta_dump()
    ds = Dataset(path).create()
    res = ds.meta_dump(on_failure='ignore')
    assert_result_count(res, 1)
    assert_result_count(
        res,
        1,
        status='impossible',
        message='metadata aggregation has never been performed '
        'in this dataset',
    )
コード例 #2
0
def test_aggregate_query(path, randompath):
    ds = Dataset(path).create(force=True)
    # no magic change to actual dataset metadata due to presence of
    # aggregated metadata
    res = ds.meta_dump(reporton='datasets', on_failure='ignore')
    assert_result_count(res, 0)
    # but we can now ask for metadata of stuff that is unknown on disk
    res = ds.meta_dump(op.join('sub', 'deep', 'some'), reporton='datasets')
    assert_result_count(res, 1)
    eq_({'homepage': 'http://top.example.com'}, res[0]['metadata'])
    sub = ds.create('sub', force=True)
    # when no reference dataset there is NO magic discovery of the relevant
    # dataset
    with chpwd(randompath):
        assert_raises(ValueError,
                      meta_dump,
                      op.join(path, 'sub', 'deep', 'some'),
                      reporton='datasets')
    # but inside a dataset things work
    with chpwd(ds.path):
        res = meta_dump(op.join(path, 'sub', 'deep', 'some'),
                        reporton='datasets')
        assert_result_count(res, 1)
        # the metadata in the discovered top dataset is return, not the
        # metadata in the subdataset
        eq_({'homepage': 'http://top.example.com'}, res[0]['metadata'])
    # when a reference dataset is given, it will be used as the metadata
    # provider
    res = sub.meta_dump(op.join('deep', 'some'), reporton='datasets')
    assert_result_count(res, 1)
    eq_({'homepage': 'http://sub.example.com'}, res[0]['metadata'])
コード例 #3
0
def test_get_aggregates_fails(path):
    with chpwd(path), assert_raises(ValueError):
        meta_dump(reporton='aggregates')
    ds = Dataset(path).create()
    res = ds.meta_dump(reporton='aggregates', on_failure='ignore')
    assert_result_count(res, 1, path=ds.path, status='impossible')