|
2 | 2 |
|
3 | 3 | import asyncio |
4 | 4 | import pickle |
| 5 | +from abc import abstractmethod |
5 | 6 | from typing import TYPE_CHECKING, Generic, TypeVar |
6 | 7 |
|
7 | 8 | from zarr.storage import WrapperStore |
@@ -37,26 +38,41 @@ class StoreTests(Generic[S, B]): |
37 | 38 | store_cls: type[S] |
38 | 39 | buffer_cls: type[B] |
39 | 40 |
|
| 41 | + @abstractmethod |
40 | 42 | async def set(self, store: S, key: str, value: Buffer) -> None: |
41 | 43 | """ |
42 | 44 | Insert a value into a storage backend, with a specific key. |
43 | 45 | This should not not use any store methods. Bypassing the store methods allows them to be |
44 | 46 | tested. |
45 | 47 | """ |
46 | | - raise NotImplementedError |
| 48 | + ... |
47 | 49 |
|
| 50 | + @abstractmethod |
48 | 51 | async def get(self, store: S, key: str) -> Buffer: |
49 | 52 | """ |
50 | 53 | Retrieve a value from a storage backend, by key. |
51 | 54 | This should not not use any store methods. Bypassing the store methods allows them to be |
52 | 55 | tested. |
53 | 56 | """ |
| 57 | + ... |
54 | 58 |
|
55 | | - raise NotImplementedError |
56 | | - |
| 59 | + @abstractmethod |
57 | 60 | @pytest.fixture |
58 | 61 | def store_kwargs(self) -> dict[str, Any]: |
59 | | - return {"read_only": False} |
| 62 | + """Kwargs for instantiating a store""" |
| 63 | + ... |
| 64 | + |
| 65 | + @abstractmethod |
| 66 | + def test_store_repr(self, store: S) -> None: ... |
| 67 | + |
| 68 | + @abstractmethod |
| 69 | + def test_store_supports_writes(self, store: S) -> None: ... |
| 70 | + |
| 71 | + @abstractmethod |
| 72 | + def test_store_supports_partial_writes(self, store: S) -> None: ... |
| 73 | + |
| 74 | + @abstractmethod |
| 75 | + def test_store_supports_listing(self, store: S) -> None: ... |
60 | 76 |
|
61 | 77 | @pytest.fixture |
62 | 78 | def open_kwargs(self, store_kwargs: dict[str, Any]) -> dict[str, Any]: |
@@ -122,18 +138,6 @@ async def test_read_only_store_raises(self, open_kwargs: dict[str, Any]) -> None |
122 | 138 | with pytest.raises(ValueError): |
123 | 139 | await store.delete("foo") |
124 | 140 |
|
125 | | - def test_store_repr(self, store: S) -> None: |
126 | | - raise NotImplementedError |
127 | | - |
128 | | - def test_store_supports_writes(self, store: S) -> None: |
129 | | - raise NotImplementedError |
130 | | - |
131 | | - def test_store_supports_partial_writes(self, store: S) -> None: |
132 | | - raise NotImplementedError |
133 | | - |
134 | | - def test_store_supports_listing(self, store: S) -> None: |
135 | | - raise NotImplementedError |
136 | | - |
137 | 141 | @pytest.mark.parametrize("key", ["c/0", "foo/c/0.0", "foo/0/0"]) |
138 | 142 | @pytest.mark.parametrize("data", [b"\x01\x02\x03\x04", b""]) |
139 | 143 | @pytest.mark.parametrize( |
|
0 commit comments