Skip to content

Commit

Permalink
Add a test case
Browse files Browse the repository at this point in the history
  • Loading branch information
jwodder committed Oct 4, 2021
1 parent ad60426 commit 731686c
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 0 deletions.
92 changes: 92 additions & 0 deletions dandi/tests/data/metadata/metadata2asset_3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"id": "dandiasset:0b0a1a0b-e3ea-4cf6-be94-e02c830d54be",
"schemaKey": "Asset",
"schemaVersion": "0.4.1",
"keywords": [
"test",
"sample",
"example",
"test-case"
],
"access": [
{
"schemaKey": "AccessRequirements",
"status": "dandi:OpenAccess"
}
],
"repository": "https://dandiarchive.org/",
"wasGeneratedBy": [
{
"schemaKey": "Session",
"identifier": "XYZ789",
"name": "XYZ789",
"description": "Some test data",
"startDate": "2020-08-31T15:58:28-04:00",
"used": [
{
"schemaKey": "Equipment",
"identifier": "probe:probe04",
"name": "Ecephys Probe"
}
]
}
],
"contentSize": 69105,
"encodingFormat": "application/x-nwb",
"digest": {
"dandi:dandi-etag": "e455839e5ab2fa659861f58a423fd17f-1"
},
"path": "/test/path",
"wasDerivedFrom": [
{
"schemaKey": "BioSample",
"identifier": "cell01",
"sampleType": {
"schemaKey": "SampleType",
"name": "cell"
},
"wasDerivedFrom": [
{
"schemaKey": "BioSample",
"identifier": "slice02",
"sampleType": {
"schemaKey": "SampleType",
"name": "slice"
},
"wasDerivedFrom": [
{
"schemaKey": "BioSample",
"identifier": "tissue03",
"sampleType": {
"schemaKey": "SampleType",
"name": "tissuesample"
}
}
]
}
]
}
],
"wasAttributedTo": [
{
"schemaKey": "Participant",
"identifier": "a1b2c3",
"age": {
"unitText": "ISO-8601 duration",
"value": "P170DT12212S",
"schemaKey": "PropertyValue",
"valueReference": {"schemaKey": "PropertyValue", "value": "dandi:BirthReference"}
},
"sex": {
"schemaKey": "SexType",
"identifier": "http://purl.obolibrary.org/obo/PATO_0000384",
"name": "Male"
},
"genotype": "Typical",
"species": {
"schemaKey": "SpeciesType",
"identifier": "https://www.example.com/unicorn"
}
}
]
}
41 changes: 41 additions & 0 deletions dandi/tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,47 @@ def test_timedelta2duration(td, duration):
"path": "/test/path",
},
),
# Put all corner cases in this test case:
(
"metadata2asset_3.json",
{
"contentSize": 69105,
"digest": "e455839e5ab2fa659861f58a423fd17f-1",
"digest_type": "dandi_etag",
"encodingFormat": "application/x-nwb",
"experiment_description": "Experiment Description",
"experimenter": "Joe Q. Experimenter",
"id": "dandiasset:0b0a1a0b-e3ea-4cf6-be94-e02c830d54be",
"institution": "University College",
"keywords": ["test", "sample", "example", "test-case"],
"lab": "Retriever Laboratory",
"related_publications": "A Brief History of Test Cases",
"session_description": "Some test data",
"session_id": "XYZ789",
"session_start_time": "2020-08-31T15:58:28-04:00",
"age": "23 days",
"date_of_birth": "2020-03-14T12:34:56-04:00",
"genotype": "Typical",
"sex": "M",
"species": "https://www.example.com/unicorn", # Corner case
"subject_id": "a1b2c3",
"cell_id": "cell01",
"slice_id": "slice02",
"tissue_sample_id": "tissue03",
"probe_ids": "probe04",
"number_of_electrodes": 42,
"number_of_units": 6,
"nwb_version": "2.2.5",
"nd_types": [
"Device (2)",
"DynamicTable",
"ElectricalSeries",
"ElectrodeGroup",
"Subject",
],
"path": "/test/path",
},
),
],
)
def test_metadata2asset(filename, metadata):
Expand Down

0 comments on commit 731686c

Please sign in to comment.