Exemplo n.º 1
0
def test_get_metadata(path):

    ds = Dataset(path).create(force=True)
    meta = MetadataParser(ds, []).get_metadata(True, False)[0]
    del meta['@context']
    dump = dumps(meta, sort_keys=True, indent=2, ensure_ascii=False)
    assert_equal(
        dump, """\
{
  "author": [
    "Mike One",
    "Anna Two"
  ],
  "citation": [
    "http://studyforrest.org"
  ],
  "comment<BIDSVersion>": "1.0.0-rc3",
  "conformsto": "http://bids.neuroimaging.io/bids_spec1.0.0-rc3.pdf",
  "description": "Some description",
  "fundedby": "We got money from collecting plastic bottles",
  "license": "PDDL",
  "name": "studyforrest_phase2"
}""")

    test_fname = opj('sub-01', 'func', 'sub-01_task-some_bold.nii.gz')
    cmeta = list(
        MetadataParser(ds,
                       [opj('sub-01', 'func', 'sub-01_task-some_bold.nii.gz')
                        ]).get_metadata(False, True)[1])
    assert_equal(len(cmeta), 1)
    assert_equal(cmeta[0][0], test_fname)
    assert_in('comment<participant#handedness>', cmeta[0][1])
Exemplo n.º 2
0
def test_get_metadata(path):

    ds = Dataset(path)
    meta = MetadataParser(ds).get_metadata('ID')
    assert_equal(
        dumps(meta, sort_keys=True, indent=2), """\
{
  "@context": {
    "@vocab": "http://schema.org/",
    "doap": "http://usefulinc.com/ns/doap#"
  },
  "@id": "ID",
  "author": [
    "Mike One",
    "Anna Two"
  ],
  "citation": [
    "http://studyforrest.org"
  ],
  "dcterms:conformsTo": [
    "http://docs.datalad.org/metadata.html#v0-1",
    "http://bids.neuroimaging.io/bids_spec1.0.0-rc3.pdf"
  ],
  "description": "Some description",
  "foaf:fundedBy": "We got money from collecting plastic bottles",
  "license": "PDDL",
  "name": "studyforrest_phase2"
}""")
Exemplo n.º 3
0
def test_get_metadata_with_README(path):
    ds = Dataset(path).create(force=True)
    meta = MetadataParser(ds, []).get_metadata(True, False)[0]
    del meta['@context']
    dump = dumps(meta, sort_keys=True, indent=2, ensure_ascii=False)
    assert_equal(
        dump, u"""\
{
  "conformsto": "http://bids.neuroimaging.io",
  "description": "A very detailed\\ndescription с юникодом",
  "name": "test"
}""")
Exemplo n.º 4
0
def test_get_metadata_with_description_and_README(path):

    ds = Dataset(path)
    meta = MetadataParser(ds).get_metadata('ID')
    assert_equal(
        dumps(meta, sort_keys=True, indent=2), """\
{
  "@context": {
    "@vocab": "http://schema.org/",
    "doap": "http://usefulinc.com/ns/doap#"
  },
  "@id": "ID",
  "dcterms:conformsTo": [
    "http://docs.datalad.org/metadata.html#v0-1",
    "http://bids.neuroimaging.io"
  ],
  "description": "Some description",
  "name": "test"
}""")
Exemplo n.º 5
0
def test_get_metadata_with_README(path):
    ds = Dataset(path)
    meta = MetadataParser(ds).get_metadata('ID')
    dump = dumps(meta, sort_keys=True, indent=2, ensure_ascii=False)
    assert_equal(
        dump, u"""\
{
  "@context": {
    "@vocab": "http://schema.org/",
    "doap": "http://usefulinc.com/ns/doap#"
  },
  "@id": "ID",
  "dcterms:conformsTo": [
    "http://docs.datalad.org/metadata.html#v0-1",
    "http://bids.neuroimaging.io"
  ],
  "description": "A very detailed\\ndescription с юникодом",
  "name": "test"
}""")
Exemplo n.º 6
0
def test_has_no_metadata(path):
    ds = Dataset(path)
    p = MetadataParser(ds)
    assert_false(p.has_metadata())
    assert_equal(p.get_core_metadata_filenames(), [])
Exemplo n.º 7
0
def test_has_metadata(path):
    ds = Dataset(path)
    p = MetadataParser(ds)
    assert_true(p.has_metadata())
    assert_equal(p.get_core_metadata_filenames(),
                 [opj(path, 'dataset_description.json')])
Exemplo n.º 8
0
def test_has_no_metadata(path):
    ds = Dataset(path)
    p = MetadataParser(ds)
    assert_false(p.has_metadata())
    assert_equal(p.get_core_metadata_filenames(), [])
Exemplo n.º 9
0
def test_has_metadata(path):
    ds = Dataset(path)
    p = MetadataParser(ds)
    assert_true(p.has_metadata())
    assert_equal(p.get_core_metadata_filenames(),
                 [opj(path, 'dataset_description.json')])