Test `open_groups` with a zarr store of an unaligned group hierarchy.
(self, unaligned_datatree_zarr_factory, zarr_format)
| 977 | "ignore:Failed to open Zarr store with consolidated metadata:RuntimeWarning" |
| 978 | ) |
| 979 | def test_open_groups(self, unaligned_datatree_zarr_factory, zarr_format) -> None: |
| 980 | """Test `open_groups` with a zarr store of an unaligned group hierarchy.""" |
| 981 | |
| 982 | storepath = unaligned_datatree_zarr_factory(zarr_format=zarr_format) |
| 983 | unaligned_dict_of_datasets = open_groups(storepath, engine="zarr") |
| 984 | |
| 985 | assert "/" in unaligned_dict_of_datasets.keys() |
| 986 | assert "/Group1" in unaligned_dict_of_datasets.keys() |
| 987 | assert "/Group1/subgroup1" in unaligned_dict_of_datasets.keys() |
| 988 | assert "/Group2" in unaligned_dict_of_datasets.keys() |
| 989 | # Check that group name returns the correct datasets |
| 990 | with xr.open_dataset(storepath, group="/", engine="zarr") as expected: |
| 991 | assert_identical(unaligned_dict_of_datasets["/"], expected) |
| 992 | with xr.open_dataset(storepath, group="Group1", engine="zarr") as expected: |
| 993 | assert_identical(unaligned_dict_of_datasets["/Group1"], expected) |
| 994 | with xr.open_dataset( |
| 995 | storepath, group="/Group1/subgroup1", engine="zarr" |
| 996 | ) as expected: |
| 997 | assert_identical(unaligned_dict_of_datasets["/Group1/subgroup1"], expected) |
| 998 | with xr.open_dataset(storepath, group="/Group2", engine="zarr") as expected: |
| 999 | assert_identical(unaligned_dict_of_datasets["/Group2"], expected) |
| 1000 | |
| 1001 | for ds in unaligned_dict_of_datasets.values(): |
| 1002 | ds.close() |
| 1003 | |
| 1004 | @pytest.mark.filterwarnings( |
| 1005 | "ignore:Failed to open Zarr store with consolidated metadata:RuntimeWarning" |
nothing calls this directly
no test coverage detected