@@ -1623,9 +1623,9 @@ async def test_create_hierarchy_invalid_mixed_format(store: Store):
16231623@pytest .mark .parametrize ("zarr_format" , [2 , 3 ]) 
16241624@pytest .mark .parametrize ("root_key" , ["" , "root" ]) 
16251625@pytest .mark .parametrize ("path" , ["" , "foo" ]) 
1626- async  def  test_group_from_flat (store : Store , zarr_format , path : str , root_key : str ):
1626+ async  def  test_create_rooted_hierarchy_group (store : Store , zarr_format , path : str , root_key : str ):
16271627    """ 
1628-     Test that the AsyncGroup.from_flat method creates  a zarr  group in one shot . 
1628+     Test that the _create_rooted_hierarchy can create  a group. 
16291629    """ 
16301630    spath  =  await  make_store_path (store , path = path )
16311631    root_meta  =  {root_key : GroupMetadata (zarr_format = zarr_format , attributes = {"path" : root_key })}
@@ -1660,6 +1660,42 @@ async def test_group_from_flat(store: Store, zarr_format, path: str, root_key: s
16601660    assert  members_observed_meta  ==  members_expected_meta_relative 
16611661
16621662
1663+ @pytest .mark .parametrize ("store" , ["memory" , "local" ], indirect = True ) 
1664+ @pytest .mark .parametrize ("zarr_format" , [2 , 3 ]) 
1665+ @pytest .mark .parametrize ("root_key" , ["" , "root" ]) 
1666+ @pytest .mark .parametrize ("path" , ["" , "foo" ]) 
1667+ async  def  test_create_rooted_hierarchy_array (store : Store , zarr_format , path : str , root_key : str ):
1668+     """ 
1669+     Test that the _create_rooted_hierarchy can create an array. 
1670+     """ 
1671+     spath  =  await  make_store_path (store , path = path )
1672+     root_meta  =  {
1673+         root_key : meta_from_array (
1674+             np .arange (3 ), zarr_format = zarr_format , attributes = {"path" : root_key }
1675+         )
1676+     }
1677+ 
1678+     nodes_create  =  root_meta 
1679+ 
1680+     a  =  await  _create_rooted_hierarchy (spath , nodes = nodes_create , overwrite = True )
1681+     assert  a .metadata .attributes  ==  {"path" : root_key }
1682+ 
1683+ 
1684+ async  def  test_create_rooted_hierarchy_invalid ():
1685+     """ 
1686+     Ensure _create_rooted_hierarchy will raise a ValueError if the input does not contain 
1687+     a root node. 
1688+     """ 
1689+     zarr_format  =  3 
1690+     nodes  =  {
1691+         "a" : GroupMetadata (zarr_format = zarr_format ),
1692+         "b" : GroupMetadata (zarr_format = zarr_format ),
1693+     }
1694+     msg  =  "The input does not specify a root node. " 
1695+     with  pytest .raises (ValueError , match = msg ):
1696+         await  _create_rooted_hierarchy (store_path = StorePath ("store" ), nodes = nodes )
1697+ 
1698+ 
16631699@pytest .mark .parametrize ("paths" , [("a" , "/a" ), ("" , "/" ), ("b/" , "b" )]) 
16641700def  test_normalize_paths_invalid (paths : tuple [str , str ]):
16651701    """ 
0 commit comments