-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add more tests for /data/ endpoint #90
Conversation
@pytest.mark.parametrize("format_arg", ("json", "bin", "npy", "csv", "tiff")) | ||
def test_data_on_array_with_format(self, server, format_arg): | ||
"""Test /data/ endpoint on array dataset""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one now tests all the supported formats without setting the other parameters. This means we no longer need to test flatten: False
and dtype: 'origin'
in subsequent tests.
|
||
retrieved_data = decode_array_response( | ||
response, format_arg, ref_dtype, data.shape | ||
f"/data/?{urlencode({'file': filename, 'path': tested_h5entity_path, 'format': format_arg, 'dtype': 'safe'})}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now focusing on testing dtype: 'safe'
in this test.
@@ -108,12 +107,31 @@ def test_data_on_slice(self, server, format_arg, flatten): | |||
h5file[tested_h5entity_path] = data | |||
|
|||
response = server.get( | |||
f"/data/?{urlencode({'file': filename, 'path': tested_h5entity_path, 'selection': '100,0', 'format': format_arg, 'flatten': flatten})}" | |||
f"/data/?{urlencode({'file': filename, 'path': tested_h5entity_path, 'selection': '100,0', 'format': format_arg, 'flatten': True})}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now focusing on testing flatten: True
in this test.
"format_arg", | ||
("csv", "npy", "tiff"), | ||
) | ||
def test_422_on_format_incompatible_with_non_numeric_data(self, server, format_arg): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To cover the condition that was moved in #89.
raise ValueError(f"Unsupported format: {format}") | ||
|
||
|
||
def decode_array_response( | ||
response: Response, | ||
format: str, | ||
dtype: str, | ||
shape: Tuple[int], | ||
shape: Tuple[int, ...], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Matching numpy's internal _Shape
type.
format=tiff
andformat=csv
with numeric arrayformat=bin
with opaque datasetThis increases the coverage by a couple of percentage points to 94%. I also reorganise the tests a bit to avoid testing the same things twice.