|
9 | 9 | import pytest |
10 | 10 |
|
11 | 11 | import zarr |
| 12 | +from zarr._info import GroupInfo |
12 | 13 | import zarr.api.asynchronous |
13 | 14 | import zarr.api.synchronous |
14 | 15 | from zarr import Array, AsyncArray, AsyncGroup, Group |
|
18 | 19 | from zarr.core.sync import sync |
19 | 20 | from zarr.errors import ContainsArrayError, ContainsGroupError |
20 | 21 | from zarr.storage import LocalStore, MemoryStore, StorePath, ZipStore |
| 22 | +import zarr.storage |
21 | 23 | from zarr.storage.common import make_store_path |
22 | 24 |
|
23 | 25 | from .conftest import parse_store |
@@ -768,15 +770,6 @@ async def test_asyncgroup_attrs(store: Store, zarr_format: ZarrFormat) -> None: |
768 | 770 | assert agroup.attrs == agroup.metadata.attributes == attributes |
769 | 771 |
|
770 | 772 |
|
771 | | -async def test_asyncgroup_info(store: Store, zarr_format: ZarrFormat) -> None: |
772 | | - agroup = await AsyncGroup.from_store( # noqa: F841 |
773 | | - store, |
774 | | - zarr_format=zarr_format, |
775 | | - ) |
776 | | - pytest.xfail("Info is not implemented for metadata yet") |
777 | | - # assert agroup.info == agroup.metadata.info |
778 | | - |
779 | | - |
780 | 773 | async def test_asyncgroup_open( |
781 | 774 | store: Store, |
782 | 775 | zarr_format: ZarrFormat, |
@@ -1322,6 +1315,34 @@ def test_from_dict_extra_fields(self): |
1322 | 1315 | assert result == expected |
1323 | 1316 |
|
1324 | 1317 |
|
| 1318 | +class TestInfo: |
| 1319 | + def test_info(self): |
| 1320 | + store = zarr.storage.MemoryStore(mode="w") |
| 1321 | + A = zarr.group(store=store, path="A") |
| 1322 | + B = A.create_group(name="B") |
| 1323 | + |
| 1324 | + B.create_array(name="x", shape=(1,)) |
| 1325 | + B.create_array(name="y", shape=(2,)) |
| 1326 | + |
| 1327 | + result = A.info |
| 1328 | + expected = GroupInfo( |
| 1329 | + name="A", |
| 1330 | + read_only=False, |
| 1331 | + store_type="MemoryStore", |
| 1332 | + ) |
| 1333 | + assert result == expected |
| 1334 | + |
| 1335 | + result = A.info_complete() |
| 1336 | + expected = GroupInfo( |
| 1337 | + name="A", |
| 1338 | + read_only=False, |
| 1339 | + store_type="MemoryStore", |
| 1340 | + count_members=3, |
| 1341 | + count_arrays=2, |
| 1342 | + count_groups=1, |
| 1343 | + ) |
| 1344 | + assert result == expected |
| 1345 | + |
1325 | 1346 | def test_update_attrs() -> None: |
1326 | 1347 | # regression test for https://github.com/zarr-developers/zarr-python/issues/2328 |
1327 | 1348 | root = Group.from_store( |
|
0 commit comments