diff --git a/dandi/tests/data/metadata/metadata2asset_3.json b/dandi/tests/data/metadata/metadata2asset_3.json new file mode 100644 index 000000000..d731453e1 --- /dev/null +++ b/dandi/tests/data/metadata/metadata2asset_3.json @@ -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" + } + } + ] +} diff --git a/dandi/tests/test_metadata.py b/dandi/tests/test_metadata.py index 9fcb7bcfd..4042132cc 100644 --- a/dandi/tests/test_metadata.py +++ b/dandi/tests/test_metadata.py @@ -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):