Skip to content

Commit

Permalink
feat: add test for streaming without write_zip
Browse files Browse the repository at this point in the history
  • Loading branch information
dnlbauer committed Jan 27, 2025
1 parent 0d81d70 commit c636220
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/test_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,3 +462,18 @@ def test_http_header(tmpdir):
assert "sdDatePublished" in props
with requests.head(url) as response:
assert props["sdDatePublished"] == response.headers.get("last-modified")


def test_stream(test_data_dir, tmpdir):
source = test_data_dir / "read_crate"
crate = ROCrate(source)

out_path = tmpdir / 'ro_crate_out.zip'
with open(out_path, "wb") as out:
for chunk in crate.stream_zip():
out.write(chunk)

with zipfile.ZipFile(out_path, "r") as zf:
assert not zf.testzip()
for info in zf.infolist():
assert info.file_size > 0

0 comments on commit c636220

Please sign in to comment.