From c2ee7e1373e2d370e773d4deeec8ced3170a8956 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Mon, 15 Apr 2024 15:00:51 -0400 Subject: [PATCH] feat(ingest): include bento DRS extension properties in ingest response --- chord_drs/routes.py | 2 +- tests/test_routes.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/chord_drs/routes.py b/chord_drs/routes.py index 248295b..6d25a9d 100644 --- a/chord_drs/routes.py +++ b/chord_drs/routes.py @@ -555,7 +555,7 @@ def object_ingest(): logger.error(f"Encountered exception during ingest: {e}") raise InternalServerError("Error while creating the object") - return build_blob_json(drs_object), 201 + return build_blob_json(drs_object, with_bento_properties=True), 201 finally: os.close(tfh) diff --git a/tests/test_routes.py b/tests/test_routes.py index 3076688..5ed6d41 100644 --- a/tests/test_routes.py +++ b/tests/test_routes.py @@ -364,7 +364,7 @@ def _ingest_one(client, existing_id=None, params=None): data = res.get_json() assert res.status_code == 201 - validate_object_fields(data, existing_id=existing_id) + validate_object_fields(data, existing_id=existing_id, with_bento_properties=True) return data @@ -387,11 +387,18 @@ def test_object_ingest_dedup(client): # ingest again, but with a different set of permissions authz_everything_true() - data_3 = _ingest_one(client, params={"project_id": "project1"}) + data_3 = _ingest_one(client, params={"project_id": "project1", "dataset_id": ""}) # dataset_id: "" -> None assert data_3["id"] != data_2["id"] assert data_3["checksums"][0]["checksum"] == data_2["checksums"][0]["checksum"] + # bento properties should exist in the ingest response: + assert data_3["bento"] + assert data_3["bento"]["project_id"] == "project1" + assert data_3["bento"]["dataset_id"] is None + assert data_3["bento"]["data_type"] is None + assert not data_3["bento"]["public"] + @responses.activate def test_object_ingest_no_deduplicate(client): @@ -426,4 +433,4 @@ def test_object_ingest_post_file(client): with open(fp, "rb") as fh: res = client.post("/ingest", data={"file": (fh, "dummy_file.txt")}, content_type="multipart/form-data") assert res.status_code == 201 - validate_object_fields(res.get_json()) + validate_object_fields(res.get_json(), with_bento_properties=True)