Skip to content

Commit

Permalink
add test_http_header
Browse files Browse the repository at this point in the history
  • Loading branch information
simleo committed Apr 10, 2024
1 parent 9e9c03a commit 1b66e14
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/test_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import io
import pytest
import requests
import os
import uuid
import sys
Expand Down Expand Up @@ -435,3 +436,19 @@ def test_add_tree(test_data_dir, tmpdir):

with pytest.raises(ValueError):
crate.add_tree(None, dest_path="foobar")


def test_http_header(tmpdir):
crate = ROCrate()
url = "https://zenodo.org/records/10782431/files/lysozyme_datasets.zip"
file_ = crate.add_file(url, validate_url=True)
assert file_.id == url
out_path = tmpdir / 'ro_crate_out'
crate.write(out_path)
out_crate = ROCrate(out_path)
out_file = out_crate.dereference(url)
props = out_file.properties()
assert props.get("encodingFormat") == "application/octet-stream"
assert "sdDatePublished" in props
with requests.head(url) as response:
assert props["sdDatePublished"] == response.headers.get("last-modified")

0 comments on commit 1b66e14

Please sign in to comment.