Skip to content

Commit

Permalink
Merge pull request #526 from dandi/json-dict-test
Browse files Browse the repository at this point in the history
Add tests of json_dict() method
  • Loading branch information
yarikoptic authored Mar 30, 2021
2 parents c10a8d9 + 90d24dd commit 08a14ff
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 4 additions & 2 deletions dandi/tests/data/metadata/metadata2asset.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,14 @@
},
"sex": {
"identifier": "http://purl.obolibrary.org/obo/PATO_0000384",
"name": "Male"
"name": "Male",
"schemaKey": "SexType"
},
"genotype": "Typical",
"species": {
"identifier": "http://purl.obolibrary.org/obo/NCBITaxon_9606",
"name": "Human"
"name": "Human",
"schemaKey": "SpeciesType"
},
"schemaKey": "Participant"
}
Expand Down
3 changes: 2 additions & 1 deletion dandi/tests/data/metadata/metadata2asset_simple1.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"sampleType": {
"name": "tissuesample",
"schemaKey": "SampleType"
}
},
"schemaKey": "BioSample"
}
],
"wasGeneratedBy": [
Expand Down
7 changes: 7 additions & 0 deletions dandi/tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ def test_metadata2asset(schema_dir):
data_as_dict = json.load(fp)
data_as_dict["schemaVersion"] = DANDI_SCHEMA_VERSION
assert data == BareAssetMeta(**data_as_dict)
bare_dict = deepcopy(data_as_dict)
bare_dict.pop("identifier")
assert data.json_dict() == bare_dict
validate_asset_json(data_as_dict, schema_dir)


Expand Down Expand Up @@ -148,6 +151,9 @@ def test_metadata2asset_simple1(schema_dir):
data_as_dict = json.load(fp)
data_as_dict["schemaVersion"] = DANDI_SCHEMA_VERSION
assert data == BareAssetMeta(**data_as_dict)
bare_dict = deepcopy(data_as_dict)
bare_dict.pop("identifier")
assert data.json_dict() == bare_dict
validate_asset_json(data_as_dict, schema_dir)


Expand All @@ -162,4 +168,5 @@ def test_dandimeta_migration(schema_dir):
data_as_dict = json.load(fp)
data_as_dict["schemaVersion"] = DANDI_SCHEMA_VERSION
assert data == DandisetMeta(**data_as_dict)
assert data.json_dict() == data_as_dict
validate_dandiset_json(data_as_dict, schema_dir)

0 comments on commit 08a14ff

Please sign in to comment.