Skip to content

Commit fb8b16d

Browse files
authored
Merge pull request #2 from maxrjones/update-tests
Update obstore tests
2 parents 77d7c12 + a95ec59 commit fb8b16d

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ test = [
7070
"mypy",
7171
"hypothesis",
7272
"universal-pathlib",
73-
"obstore==0.3.0b8",
73+
"obstore==0.3.0b9",
7474
]
7575

7676
jupyter = [

src/zarr/storage/object_store.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,29 @@ def __eq__(self, value: object) -> bool:
3838
if not isinstance(value, ObjectStore):
3939
return False
4040

41-
return self.store.__eq__(value.store)
41+
return bool(self.store.__eq__(value.store))
4242

4343
def __init__(self, store: _ObjectStore, *, read_only: bool = False) -> None:
44+
if not isinstance(
45+
store,
46+
(
47+
obs.store.AzureStore,
48+
obs.store.GCSStore,
49+
obs.store.HTTPStore,
50+
obs.store.S3Store,
51+
obs.store.LocalStore,
52+
obs.store.MemoryStore,
53+
),
54+
):
55+
raise TypeError(f"expected ObjectStore class, got {store!r}")
4456
self.store = store
45-
4657
super().__init__(read_only=read_only)
4758

4859
def __str__(self) -> str:
4960
return f"object://{self.store}"
5061

5162
def __repr__(self) -> str:
52-
return f"ObjectStore({self!r})"
63+
return f"ObjectStore({self})"
5364

5465
async def get(
5566
self, key: str, prototype: BufferPrototype, byte_range: ByteRangeRequest | None = None

tests/test_store/test_object.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ruff: noqa: E402
22
import pytest
33

4-
pytest.importorskip("obstore")
4+
obstore = pytest.importorskip("obstore")
55

66
from zarr.core.buffer import cpu
77
from zarr.storage.object_store import ObjectStore
@@ -10,3 +10,13 @@
1010

1111
class TestObjectStore(StoreTests[ObjectStore, cpu.Buffer]):
1212
store_cls = ObjectStore
13+
buffer_cls = cpu.Buffer
14+
15+
@pytest.fixture
16+
def store_kwargs(self, tmpdir) -> dict[str, str | bool]:
17+
store = obstore.store.LocalStore(prefix=tmpdir)
18+
return {"store": store, "read_only": False}
19+
20+
@pytest.fixture
21+
def store(self, store_kwargs: dict[str, str | bool]) -> ObjectStore:
22+
return self.store_cls(**store_kwargs)

0 commit comments

Comments
 (0)