Skip to content

Commit 1abaab6

Browse files
committed
add failing tests
1 parent c37e69d commit 1abaab6

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

tests/test_group.py

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -338,13 +338,19 @@ def test_group_members(store: Store, zarr_format: ZarrFormat, consolidated_metad
338338

339339
@pytest.fixture
340340
def copy_to_test_data(
341-
request,
341+
request: pytest.FixtureRequest,
342342
) -> tuple[Group, np.ndarray[Any, np.dtype[Any]], np.ndarray[Any, np.dtype[Any]], int, bool]:
343343
"""Fixture that creates test data for copy_to tests."""
344-
zarr_format, shards, consolidate_metadata = request.param
344+
zarr_format, shards, consolidate_metadata, src_path = request.param
345345

346346
src_store = MemoryStore()
347-
src = Group.from_store(src_store, attributes={"root": True}, zarr_format=zarr_format)
347+
src = zarr.open_group(
348+
src_store,
349+
path=src_path or None,
350+
mode="w",
351+
zarr_format=zarr_format,
352+
attributes={"root": True},
353+
)
348354

349355
subgroup = src.create_group("subgroup", attributes={"subgroup": True})
350356

@@ -368,23 +374,28 @@ def copy_to_test_data(
368374
)
369375
src["dataset"] = arr_data
370376

371-
src = consolidate(src_store, src, consolidate_metadata, zarr_format)
377+
src = consolidate(src_store, src, consolidate_metadata, zarr_format, path=src_path)
372378

373379
return src, arr_data, subgroup_arr_data, zarr_format, consolidate_metadata
374380

375381

376382
def consolidate(
377-
src_store: MemoryStore, src: Group, consolidate_metadata: bool, zarr_format: int
383+
src_store: MemoryStore,
384+
src: Group,
385+
consolidate_metadata: bool,
386+
zarr_format: int,
387+
path: str = "",
378388
) -> Group:
379389
if consolidate_metadata:
390+
subgroup_path = f"{path}/subgroup" if path else "subgroup"
380391
if zarr_format == 3:
381392
with pytest.warns(ZarrUserWarning, match="Consolidated metadata is currently"):
382-
src = zarr.consolidate_metadata(src_store)
393+
src = zarr.consolidate_metadata(src_store, path=path)
383394
with pytest.warns(ZarrUserWarning, match="Consolidated metadata is currently"):
384-
zarr.consolidate_metadata(src_store, path="subgroup")
395+
zarr.consolidate_metadata(src_store, path=subgroup_path)
385396
else:
386-
src = zarr.consolidate_metadata(src_store)
387-
zarr.consolidate_metadata(src_store, path="subgroup")
397+
src = zarr.consolidate_metadata(src_store, path=path)
398+
zarr.consolidate_metadata(src_store, path=subgroup_path)
388399
return src
389400

390401

@@ -407,10 +418,11 @@ def check_consolidated_metadata(
407418
@pytest.mark.parametrize(
408419
"copy_to_test_data",
409420
[
410-
(2, None, False),
411-
(2, None, True),
412-
(3, (50,), False),
413-
(3, (50,), True),
421+
(2, None, False, ""),
422+
(2, None, True, ""),
423+
(3, (50,), False, ""),
424+
(3, (50,), True, ""),
425+
(3, (50,), False, "nested/source"),
414426
],
415427
indirect=True,
416428
)
@@ -445,10 +457,11 @@ def test_copy_to(
445457
@pytest.mark.parametrize(
446458
"copy_to_test_data",
447459
[
448-
(2, None, False),
449-
(2, None, True),
450-
(3, (50,), False),
451-
(3, (50,), True),
460+
(2, None, False, ""),
461+
(2, None, True, ""),
462+
(3, (50,), False, ""),
463+
(3, (50,), True, ""),
464+
(3, (50,), False, "nested/source"),
452465
],
453466
indirect=True,
454467
)

0 commit comments

Comments
 (0)