Skip to content

Commit

Permalink
feat(ingest): include bento DRS extension properties in ingest response
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Apr 15, 2024
1 parent 4b3637c commit c2ee7e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion chord_drs/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 10 additions & 3 deletions tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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):
Expand Down Expand Up @@ -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)

0 comments on commit c2ee7e1

Please sign in to comment.