@@ -86,10 +86,12 @@ def s3(s3_base: None) -> Generator[s3fs.S3FileSystem, None, None]:
8686
8787async def test_basic () -> None :
8888 store = RemoteStore .from_url (
89- f"s3://{ test_bucket_name } " ,
89+ f"s3://{ test_bucket_name } /foo/spam/ " ,
9090 mode = "w" ,
9191 storage_options = {"endpoint_url" : endpoint_url , "anon" : False },
9292 )
93+ assert store .fs .asynchronous
94+ assert store .path == f"{ test_bucket_name } /foo/spam"
9395 assert await _collect_aiterator (store .list ()) == ()
9496 assert not await store .exists ("foo" )
9597 data = b"hello"
@@ -109,7 +111,7 @@ class TestRemoteStoreS3(StoreTests[RemoteStore, cpu.Buffer]):
109111 @pytest .fixture
110112 def store_kwargs (self , request ) -> dict [str , str | bool ]:
111113 fs , path = fsspec .url_to_fs (
112- f"s3://{ test_bucket_name } " , endpoint_url = endpoint_url , anon = False
114+ f"s3://{ test_bucket_name } " , endpoint_url = endpoint_url , anon = False , asynchronous = True
113115 )
114116 return {"fs" : fs , "path" : path , "mode" : "r+" }
115117
@@ -143,9 +145,7 @@ def test_store_supports_partial_writes(self, store: RemoteStore) -> None:
143145 def test_store_supports_listing (self , store : RemoteStore ) -> None :
144146 assert store .supports_listing
145147
146- async def test_remote_store_from_uri (
147- self , store : RemoteStore , store_kwargs : dict [str , str | bool ]
148- ):
148+ async def test_remote_store_from_uri (self , store : RemoteStore ):
149149 storage_options = {
150150 "endpoint_url" : endpoint_url ,
151151 "anon" : False ,
@@ -183,9 +183,32 @@ async def test_remote_store_from_uri(
183183 assert dict (group .attrs ) == {"key" : "value-3" }
184184
185185 def test_from_upath (self ) -> None :
186- path = UPath (f"s3://{ test_bucket_name } " , endpoint_url = endpoint_url , anon = False )
186+ path = UPath (
187+ f"s3://{ test_bucket_name } /foo/bar/" ,
188+ endpoint_url = endpoint_url ,
189+ anon = False ,
190+ asynchronous = True ,
191+ )
187192 result = RemoteStore .from_upath (path )
188193 assert result .fs .endpoint_url == endpoint_url
194+ assert result .fs .asynchronous
195+ assert result .path == f"{ test_bucket_name } /foo/bar"
196+
197+ def test_init_raises_if_path_has_scheme (self , store_kwargs ) -> None :
198+ # regression test for https://github.com/zarr-developers/zarr-python/issues/2342
199+ store_kwargs ["path" ] = "s3://" + store_kwargs ["path" ]
200+ with pytest .raises (
201+ ValueError , match = "path argument to RemoteStore must not include scheme .*"
202+ ):
203+ self .store_cls (** store_kwargs )
204+
205+ def test_init_warns_if_fs_asynchronous_is_false (self ) -> None :
206+ fs , path = fsspec .url_to_fs (
207+ f"s3://{ test_bucket_name } " , endpoint_url = endpoint_url , anon = False , asynchronous = False
208+ )
209+ store_kwargs = {"fs" : fs , "path" : path , "mode" : "r+" }
210+ with pytest .warns (UserWarning , match = r".* was not created with `asynchronous=True`.*" ):
211+ self .store_cls (** store_kwargs )
189212
190213 async def test_empty_nonexistent_path (self , store_kwargs ) -> None :
191214 # regression test for https://github.com/zarr-developers/zarr-python/pull/2343
0 commit comments