Skip to content

Commit

Permalink
Test /data/ endpoint with opaque dataset and binary format
Browse files Browse the repository at this point in the history
  • Loading branch information
axelboc committed Mar 11, 2024
1 parent 3d72ba2 commit 7eda6df
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,25 @@ def test_data_on_slice_with_format_and_flatten(self, server, format_arg):

assert retrieved_data - data[100, 0] < 1e-8

def test_data_on_opaque(self, server):
"""Test /data/ endpoint on opaque dataset with format=bin"""
tested_h5entity_path = "/opaque"
data = np.void(b"\x00")

filename = "test.h5"
with h5py.File(server.served_directory / filename, mode="w") as h5file:
h5file[tested_h5entity_path] = data

response = server.get(
f"/data/?{urlencode({'file': filename, 'path': tested_h5entity_path, 'format': 'bin'})}"
)

content_type = response.find_header_value("content-type")
assert content_type == "application/octet-stream"

retrieved_data = np.void(response.content)
assert np.array_equal(retrieved_data, data)

def test_meta_on_chunked_compressed_dataset(self, server):
"""Test /meta/ endpoint on a chunked and compressed dataset"""
filename = "test.h5"
Expand Down

0 comments on commit 7eda6df

Please sign in to comment.