Skip to content

Commit

Permalink
Merge pull request #237 from dandi/moretests
Browse files Browse the repository at this point in the history
Still more API tests
  • Loading branch information
jwodder authored Jan 29, 2025
2 parents de121f4 + a2f216b commit 364ac81
Show file tree
Hide file tree
Showing 143 changed files with 6,371 additions and 42 deletions.
20 changes: 20 additions & 0 deletions crates/genstubs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ fn main() -> anyhow::Result<()> {
},
metadata: v.metadata,
assets,
assets_req: v.assets,
asset_dirs: v.asset_dirs,
});
}
Expand Down Expand Up @@ -201,6 +202,22 @@ fn main() -> anyhow::Result<()> {
));
}
}
for apath in &v.assets_req {
let assets = v
.assets
.iter()
.filter(|a| a.properties.path.starts_with(apath))
.collect::<Vec<_>>();
assets_responses.extend(paginate(
&assets,
&format!("/api/dandisets/{}/versions/{}/assets/", d.id, v.id),
BTreeMap::from([
("metadata".to_owned(), "1".to_owned()),
("order".to_owned(), "path".to_owned()),
("path".to_owned(), apath.clone()),
]),
));
}
if !assets_responses.is_empty() {
dump_json(
&assets_responses,
Expand Down Expand Up @@ -305,6 +322,8 @@ struct VersionSpec {
modified: String,
metadata: serde_json::Value,
#[serde(default)]
assets: Vec<String>,
#[serde(default)]
asset_dirs: Vec<Option<String>>,
}

Expand Down Expand Up @@ -368,6 +387,7 @@ struct Version {
api_payload: ApiVersion,
metadata: serde_json::Value,
assets: Vec<Asset>,
assets_req: Vec<String>,
asset_dirs: Vec<Option<String>>,
}

Expand Down
9 changes: 5 additions & 4 deletions doc/mocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,16 @@ is an object with the following fields:
- `created` — timestamp
- `modified` — timestamp
- `metadata` — arbitrary JSON-compatible data
- `assets` *(optional)* — A list of asset paths that the tests will query
for and thus that appropriate stubs should be generated for.
- `asset_dirs` *(optional)* — A list of asset directory paths (sans trailing
slash) that the tests will query for and thus that appropriate stubs should
be generated for. A path of `null` denotes the root directory.

There must be one version with a `version` value of "draft". The non-draft
version with the latest `created` date, if any, becomes the most recent
published version.

- `asset_dirs` *(optional)* — A list of asset directory paths (sans trailing
slash) that the tests will query for and thus that appropriate stubs should
be generated for. A path of `null` denotes the root directory.

### Asset Listings

Asset files contains a list of assets, each of which is an object with the following fields:
Expand Down
6 changes: 6 additions & 0 deletions mockspecs/dandisets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
version: "draft"
dateCreated: "2020-03-15T22:56:55.655000+00:00"
description: "Researcher is seeking funding for surgery to fix goring injuries."
assets:
- sub-RAT123/sub-RAT123.nwb

- version: "0.210512.1623"
name: "Brainscan of a Unicorn"
Expand Down Expand Up @@ -54,6 +56,8 @@
version: "0.230629.1955"
dateCreated: "2023-06-29T19:55:31.388489Z"
description: "Researcher is seeking funding for surgery to fix goring injuries."
asset_dirs:
- null

- identifier: "000002"
created: "2020-03-16T21:48:04.265000Z"
Expand Down Expand Up @@ -120,3 +124,5 @@
version: "draft"
dateCreated: "2020-03-16T22:52:44.757000Z"
description: "Researcher will soon be leaving for new life under the sea."
asset_dirs:
- null
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"params": {},
"response": {
"asset_id": "34523ca7-ff7c-42b3-a311-2f2d0ccc780f",
"blob": "ac084d90-0350-40dd-9219-917396a8d662",
"zarr": null,
"path": "PYQIm.tsv",
"size": 7057,
"created": "2020-08-17T10:19:11.502133+00:00",
"modified": "2024-06-05T02:34:12.137986+00:00",
"metadata": {
"@context": "https://raw.githubusercontent.com/dandi/schema/master/releases/0.6.3/context.json",
"blobDateModified": "2024-05-27T19:41:30.605116+00:00",
"contentSize": 7057,
"contentUrl": [
"https://api.dandiarchive.org/api/assets/34523ca7-ff7c-42b3-a311-2f2d0ccc780f/download/",
"https://dandiarchive.s3.amazonaws.com/blobs/ac0/84d/ac084d90-0350-40dd-9219-917396a8d662"
],
"dateModified": "2024-05-14T01:20:02.496242+00:00",
"digest": {
"dandi:dandi-etag": "e2db9c2ea7205aaf18b0d9d0fb32bdd1-1",
"dandi:sha2-256": "737d6861af41eb47fe296a63b60eb9fe946259fedaf0371bf9132706863757a9"
},
"encodingFormat": "text/tab-separated-values",
"id": "dandiasset:34523ca7-ff7c-42b3-a311-2f2d0ccc780f",
"identifier": "34523ca7-ff7c-42b3-a311-2f2d0ccc780f",
"path": "PYQIm.tsv",
"schemaKey": "Asset",
"schemaVersion": "0.6.3"
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"params": {},
"response": {
"asset_id": "6d8e773d-fb9c-45e6-9a14-2c249399a901",
"blob": "d6085a84-a0ac-47e5-b495-209459cf1cab",
"zarr": null,
"path": "mv.nwb",
"size": 14960,
"created": "2022-11-14T02:46:29.000343+00:00",
"modified": "2024-09-23T17:50:51.114126+00:00",
"metadata": {
"@context": "https://raw.githubusercontent.com/dandi/schema/master/releases/0.6.3/context.json",
"blobDateModified": "2023-02-12T20:40:11.178345+00:00",
"contentSize": 14960,
"contentUrl": [
"https://api.dandiarchive.org/api/assets/6d8e773d-fb9c-45e6-9a14-2c249399a901/download/",
"https://dandiarchive.s3.amazonaws.com/blobs/d60/85a/d6085a84-a0ac-47e5-b495-209459cf1cab"
],
"dateModified": "2022-12-24T01:42:17.157210+00:00",
"digest": {
"dandi:dandi-etag": "3e76fc676ea683ac2b45efe7ee177d0e-1",
"dandi:sha2-256": "2581d8334c4116c61d1fb3440a82310bb6f5c29f1443a2a41bb73a4bd04f5953"
},
"encodingFormat": "application/x-nwb",
"id": "dandiasset:6d8e773d-fb9c-45e6-9a14-2c249399a901",
"identifier": "6d8e773d-fb9c-45e6-9a14-2c249399a901",
"path": "mv.nwb",
"schemaKey": "Asset",
"schemaVersion": "0.6.3"
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"params": {},
"response": {
"asset_id": "864dffcb-61f7-4a1a-b26c-462739931efa",
"blob": "ce2e612d-e5db-4069-932a-8b01ae1bc3e3",
"zarr": null,
"path": "yCw7krL6rM.nwb",
"size": 7126,
"created": "2022-03-19T20:29:49.950482+00:00",
"modified": "2024-10-16T15:26:16.561704+00:00",
"metadata": {
"@context": "https://raw.githubusercontent.com/dandi/schema/master/releases/0.6.3/context.json",
"blobDateModified": "2024-09-25T21:55:36.441081+00:00",
"contentSize": 7126,
"contentUrl": [
"https://api.dandiarchive.org/api/assets/864dffcb-61f7-4a1a-b26c-462739931efa/download/",
"https://dandiarchive.s3.amazonaws.com/blobs/ce2/e61/ce2e612d-e5db-4069-932a-8b01ae1bc3e3"
],
"dateModified": "2024-02-24T06:43:07.234363+00:00",
"digest": {
"dandi:dandi-etag": "6fdc72cfb54adfb102754a4809b43610-1",
"dandi:sha2-256": "7b958d68ee17e77e8cc14ca8c8068c3fa01d4f4ad3e0b25ec8db7a67707bff3e"
},
"encodingFormat": "application/x-nwb",
"id": "dandiasset:864dffcb-61f7-4a1a-b26c-462739931efa",
"identifier": "864dffcb-61f7-4a1a-b26c-462739931efa",
"path": "yCw7krL6rM.nwb",
"schemaKey": "Asset",
"schemaVersion": "0.6.3"
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"params": {},
"response": {
"asset_id": "86645ab4-782a-403e-9e1a-f65df91b70a9",
"blob": "9431cd84-3694-4a74-a4c7-1cf6114b38f3",
"zarr": null,
"path": "OK.nwb",
"size": 14435,
"created": "2021-04-07T15:29:52.823233+00:00",
"modified": "2024-12-29T20:05:23.137688+00:00",
"metadata": {
"@context": "https://raw.githubusercontent.com/dandi/schema/master/releases/0.6.3/context.json",
"blobDateModified": "2024-11-24T05:21:10.729198+00:00",
"contentSize": 14435,
"contentUrl": [
"https://api.dandiarchive.org/api/assets/86645ab4-782a-403e-9e1a-f65df91b70a9/download/",
"https://dandiarchive.s3.amazonaws.com/blobs/943/1cd/9431cd84-3694-4a74-a4c7-1cf6114b38f3"
],
"dateModified": "2024-05-07T09:00:57.581014+00:00",
"digest": {
"dandi:dandi-etag": "9fbb0820830c6d8fb7be5b2b0132d077-1",
"dandi:sha2-256": "58fdb292691f4523bd7a7185ff32305827e133b5b8619dccd792923759048ce8"
},
"encodingFormat": "application/x-nwb",
"id": "dandiasset:86645ab4-782a-403e-9e1a-f65df91b70a9",
"identifier": "86645ab4-782a-403e-9e1a-f65df91b70a9",
"path": "OK.nwb",
"schemaKey": "Asset",
"schemaVersion": "0.6.3"
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[
{
"params": {},
"response": {
"asset_id": "9bb35766-4d95-48d7-88df-68a23cd43b74",
"blob": null,
"zarr": "c9ea4a58-713c-4f2d-ba2e-2aa7e71e3ffd",
"path": "b.zarr",
"size": 128569,
"created": "2021-04-04T04:17:58.536162+00:00",
"modified": "2024-07-07T10:10:04.539625+00:00",
"metadata": {
"@context": "https://raw.githubusercontent.com/dandi/schema/master/releases/0.6.3/context.json",
"blobDateModified": "2024-05-02T16:34:51.278044+00:00",
"contentSize": 128569,
"contentUrl": [
"https://api.dandiarchive.org/api/assets/9bb35766-4d95-48d7-88df-68a23cd43b74/download/",
"https://dandiarchive.s3.amazonaws.com/zarr/c9ea4a58-713c-4f2d-ba2e-2aa7e71e3ffd/"
],
"dateModified": "2024-01-04T23:50:20.686998+00:00",
"digest": {
"dandi:dandi-zarr-checksum": "487b960454741ea93e730b760c1316dc-280--128569"
},
"encodingFormat": "application/x-zarr",
"id": "dandiasset:9bb35766-4d95-48d7-88df-68a23cd43b74",
"identifier": "9bb35766-4d95-48d7-88df-68a23cd43b74",
"path": "b.zarr",
"schemaKey": "Asset",
"schemaVersion": "0.6.3"
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"params": {},
"response": {
"asset_id": "af17d53e-1bbf-473b-9a3c-5ca32db1e90d",
"blob": "feca91a8-f51e-4121-a8cf-25558e170c9b",
"zarr": null,
"path": "9coP.nwb",
"size": 3884,
"created": "2020-05-09T00:21:08.514671+00:00",
"modified": "2023-01-29T18:58:27.289916+00:00",
"metadata": {
"@context": "https://raw.githubusercontent.com/dandi/schema/master/releases/0.6.3/context.json",
"blobDateModified": "2021-12-27T11:00:25.659725+00:00",
"contentSize": 3884,
"contentUrl": [
"https://api.dandiarchive.org/api/assets/af17d53e-1bbf-473b-9a3c-5ca32db1e90d/download/",
"https://dandiarchive.s3.amazonaws.com/blobs/fec/a91/feca91a8-f51e-4121-a8cf-25558e170c9b"
],
"dateModified": "2021-08-15T04:27:13.961652+00:00",
"digest": {
"dandi:dandi-etag": "38a8ecbce7344eb3545a3038cce23398-1",
"dandi:sha2-256": "512098118c9ded77aa52815b3f15188b185840c8af8409c130413f5dcdeaaabd"
},
"encodingFormat": "application/x-nwb",
"id": "dandiasset:af17d53e-1bbf-473b-9a3c-5ca32db1e90d",
"identifier": "af17d53e-1bbf-473b-9a3c-5ca32db1e90d",
"path": "9coP.nwb",
"schemaKey": "Asset",
"schemaVersion": "0.6.3"
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[
{
"params": {},
"response": {
"count": 6,
"next": null,
"results": [
{
"path": "9coP.nwb",
"aggregate_files": 1,
"aggregate_size": 3884,
"asset": {
"asset_id": "af17d53e-1bbf-473b-9a3c-5ca32db1e90d"
}
},
{
"path": "OK.nwb",
"aggregate_files": 1,
"aggregate_size": 14435,
"asset": {
"asset_id": "86645ab4-782a-403e-9e1a-f65df91b70a9"
}
},
{
"path": "PYQIm.tsv",
"aggregate_files": 1,
"aggregate_size": 7057,
"asset": {
"asset_id": "34523ca7-ff7c-42b3-a311-2f2d0ccc780f"
}
},
{
"path": "b.zarr",
"aggregate_files": 1,
"aggregate_size": 128569,
"asset": {
"asset_id": "9bb35766-4d95-48d7-88df-68a23cd43b74"
}
},
{
"path": "mv.nwb",
"aggregate_files": 1,
"aggregate_size": 14960,
"asset": {
"asset_id": "6d8e773d-fb9c-45e6-9a14-2c249399a901"
}
},
{
"path": "yCw7krL6rM.nwb",
"aggregate_files": 1,
"aggregate_size": 7126,
"asset": {
"asset_id": "864dffcb-61f7-4a1a-b26c-462739931efa"
}
}
]
}
}
]
Loading

0 comments on commit 364ac81

Please sign in to comment.