@@ -653,16 +653,18 @@ async def test_consolidated_metadata_encodes_special_chars(
653653 assert root_metadata ["time" ]["fill_value" ] == expected_fill_value
654654
655655
656+ class NonConsolidatedStore (zarr .storage .MemoryStore ):
657+ """A store that doesn't support consolidated metadata"""
658+
659+ @property
660+ def supports_consolidated_metadata (self ) -> bool :
661+ return False
662+
663+
656664async def test_consolidate_metadata_is_noop_for_self_consolidating_stores ():
657665 """Verify calling consolidate_metadata on a non supporting stores does nothing"""
658666
659- # We create a store that doesn't support consolidated metadata
660- class Store (zarr .storage .MemoryStore ):
661- @property
662- def supports_consolidated_metadata (self ) -> bool :
663- return False
664-
665- memory_store = Store ()
667+ memory_store = NonConsolidatedStore ()
666668 root = await zarr .api .asynchronous .create_group (store = memory_store )
667669 await root .create_group ("a/b" )
668670
@@ -672,6 +674,22 @@ async def set_raises(self, value: Buffer, byte_range: ByteRequest | None = None)
672674
673675 memory_store .set = set_raises
674676
675- # consolidate_metadata would call `set` if the store supported consolidated metadata
676- # if this doesn't raise, it means consolidate_metadata is NOOP
677- await zarr .api .asynchronous .consolidate_metadata (memory_store )
677+ with pytest .warns (UserWarning , match = "doesn't support consolidated metadata" ):
678+ # consolidate_metadata would call `set` if the store supported consolidated metadata
679+ # if this doesn't raise, it means consolidate_metadata is NOOP
680+ await zarr .api .asynchronous .consolidate_metadata (memory_store )
681+
682+
683+ async def test_open_group_in_non_consolidating_stores ():
684+ memory_store = NonConsolidatedStore ()
685+ root = await zarr .api .asynchronous .create_group (store = memory_store )
686+ await root .create_group ("a/b" )
687+
688+ # Opening a group without consolidatedion works as expected
689+ await AsyncGroup .open (memory_store , use_consolidated = False )
690+
691+ # Opening a group with use_consolidated=True should warn
692+ with pytest .warns (
693+ UserWarning , match = "doesn't support consolidated metadata.*Ignoring use_consolidated=True"
694+ ):
695+ await AsyncGroup .open (memory_store , use_consolidated = True )
0 commit comments