Skip to content

Commit

Permalink
* test: data copier with and invalid features
Browse files Browse the repository at this point in the history
* test: data copier with  and invalid features

* test: modify value error

---------

Co-authored-by: ralajan <raghava.alajangi@mpl.mpg.de>
  • Loading branch information
RaghavaAlajangi and ralajan committed Jan 26, 2024
1 parent aac7754 commit 3b3fe6f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
0.57.2
- test: data copier with `none` and invalid features
- enh: allow to specify list of features for data copier
- build: make musllinux builds for e.g. docker images
0.57.1
Expand Down
35 changes: 35 additions & 0 deletions tests/test_rtdc_copier.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,3 +230,38 @@ def test_copy_specified_feature_list():
assert "image" in hc["events"]
assert "area_um" not in hc["events"]
assert "deform" in hc["events"]


def test_do_not_copy_features():
path = retrieve_data("fmt-hdf5_image-bg_2020.zip")
path_copy = path.with_name("test_copy.rtdc")

# copy
with h5py.File(path) as h5, h5py.File(path_copy, "w") as hc:
# make sure image data is there
assert "image" in h5["events"]
assert "deform" in h5["events"]
rtdc_copy(src_h5file=h5,
dst_h5file=hc,
features="none")

# Make sure this worked
with h5py.File(path_copy) as hc:
assert "events" not in hc


def test_copier_with_wrong_feature():
path = retrieve_data("fmt-hdf5_image-bg_2020.zip")
path_copy = path.with_name("test_copy.rtdc")

# copy
with h5py.File(path) as h5, h5py.File(path_copy, "w") as hc:
# make sure image data is there
assert "image" in h5["events"]
assert "deform" in h5["events"]
with pytest.raises(ValueError,
match="must be either a list of feature names"):
rtdc_copy(src_h5file=h5,
dst_h5file=hc,
features="invalid")
assert "events" not in hc

0 comments on commit 3b3fe6f

Please sign in to comment.