Skip to content

Commit 842f712

Browse files
committed
add to_internal unit test
1 parent 3aef395 commit 842f712

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

asdf_zarr/tests/test_zarr.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,19 @@ def test_open_mode(tmp_path, mode):
129129
af["arr"][0, 0] = 1
130130
else:
131131
raise Exception(f"Unknown mode {mode}")
132+
133+
134+
@pytest.mark.parametrize("meta_store", [True, False])
135+
def test_to_internal(meta_store):
136+
if meta_store:
137+
zarr = create_zarray(store=KVStore({}), chunk_store=TempStore())
138+
else:
139+
zarr = create_zarray(store=TempStore())
140+
internal = asdf_zarr.storage.to_internal(zarr)
141+
assert isinstance(internal.chunk_store, asdf_zarr.storage.InternalStore)
142+
# the store shouldn't be wrapped if it's not used for chunks
143+
if zarr.store is not zarr.chunk_store:
144+
assert isinstance(internal.store, KVStore)
145+
# calling it a second time shouldn't re-wrap the store
146+
same = asdf_zarr.storage.to_internal(internal)
147+
assert same.chunk_store is internal.chunk_store

0 commit comments

Comments
 (0)