fsspec 2024.5.0__py3-none-any.whl → 2024.6.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fsspec/_version.py +2 -2
- fsspec/caching.py +3 -2
- fsspec/compression.py +1 -1
- fsspec/generic.py +3 -0
- fsspec/implementations/cached.py +6 -16
- fsspec/implementations/dirfs.py +2 -0
- fsspec/implementations/github.py +12 -0
- fsspec/implementations/http.py +2 -1
- fsspec/implementations/reference.py +9 -0
- fsspec/implementations/smb.py +10 -0
- fsspec/json.py +121 -0
- fsspec/registry.py +24 -18
- fsspec/spec.py +119 -33
- fsspec/utils.py +1 -1
- {fsspec-2024.5.0.dist-info → fsspec-2024.6.1.dist-info}/METADATA +10 -5
- fsspec-2024.6.1.dist-info/RECORD +55 -0
- {fsspec-2024.5.0.dist-info → fsspec-2024.6.1.dist-info}/WHEEL +1 -1
- fsspec/implementations/tests/__init__.py +0 -0
- fsspec/implementations/tests/cassettes/test_dbfs/test_dbfs_file_listing.yaml +0 -112
- fsspec/implementations/tests/cassettes/test_dbfs/test_dbfs_mkdir.yaml +0 -582
- fsspec/implementations/tests/cassettes/test_dbfs/test_dbfs_read_pyarrow_non_partitioned.yaml +0 -873
- fsspec/implementations/tests/cassettes/test_dbfs/test_dbfs_read_range.yaml +0 -458
- fsspec/implementations/tests/cassettes/test_dbfs/test_dbfs_read_range_chunked.yaml +0 -1355
- fsspec/implementations/tests/cassettes/test_dbfs/test_dbfs_write_and_read.yaml +0 -795
- fsspec/implementations/tests/cassettes/test_dbfs/test_dbfs_write_pyarrow_non_partitioned.yaml +0 -613
- fsspec/implementations/tests/conftest.py +0 -39
- fsspec/implementations/tests/local/__init__.py +0 -0
- fsspec/implementations/tests/local/local_fixtures.py +0 -18
- fsspec/implementations/tests/local/local_test.py +0 -14
- fsspec/implementations/tests/memory/__init__.py +0 -0
- fsspec/implementations/tests/memory/memory_fixtures.py +0 -27
- fsspec/implementations/tests/memory/memory_test.py +0 -14
- fsspec/implementations/tests/out.zip +0 -0
- fsspec/implementations/tests/test_archive.py +0 -382
- fsspec/implementations/tests/test_arrow.py +0 -259
- fsspec/implementations/tests/test_cached.py +0 -1306
- fsspec/implementations/tests/test_common.py +0 -35
- fsspec/implementations/tests/test_dask.py +0 -29
- fsspec/implementations/tests/test_data.py +0 -20
- fsspec/implementations/tests/test_dbfs.py +0 -268
- fsspec/implementations/tests/test_dirfs.py +0 -588
- fsspec/implementations/tests/test_ftp.py +0 -178
- fsspec/implementations/tests/test_git.py +0 -76
- fsspec/implementations/tests/test_http.py +0 -577
- fsspec/implementations/tests/test_jupyter.py +0 -57
- fsspec/implementations/tests/test_libarchive.py +0 -33
- fsspec/implementations/tests/test_local.py +0 -1285
- fsspec/implementations/tests/test_memory.py +0 -382
- fsspec/implementations/tests/test_reference.py +0 -720
- fsspec/implementations/tests/test_sftp.py +0 -233
- fsspec/implementations/tests/test_smb.py +0 -139
- fsspec/implementations/tests/test_tar.py +0 -243
- fsspec/implementations/tests/test_webhdfs.py +0 -197
- fsspec/implementations/tests/test_zip.py +0 -134
- fsspec/tests/__init__.py +0 -0
- fsspec/tests/conftest.py +0 -188
- fsspec/tests/data/listing.html +0 -1
- fsspec/tests/test_api.py +0 -498
- fsspec/tests/test_async.py +0 -230
- fsspec/tests/test_caches.py +0 -255
- fsspec/tests/test_callbacks.py +0 -89
- fsspec/tests/test_compression.py +0 -164
- fsspec/tests/test_config.py +0 -129
- fsspec/tests/test_core.py +0 -466
- fsspec/tests/test_downstream.py +0 -40
- fsspec/tests/test_file.py +0 -200
- fsspec/tests/test_fuse.py +0 -147
- fsspec/tests/test_generic.py +0 -90
- fsspec/tests/test_gui.py +0 -23
- fsspec/tests/test_mapping.py +0 -228
- fsspec/tests/test_parquet.py +0 -140
- fsspec/tests/test_registry.py +0 -134
- fsspec/tests/test_spec.py +0 -1167
- fsspec/tests/test_utils.py +0 -478
- fsspec-2024.5.0.dist-info/RECORD +0 -111
- {fsspec-2024.5.0.dist-info → fsspec-2024.6.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,588 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
|
|
3
|
-
from fsspec.asyn import AsyncFileSystem
|
|
4
|
-
from fsspec.implementations.dirfs import DirFileSystem
|
|
5
|
-
from fsspec.spec import AbstractFileSystem
|
|
6
|
-
|
|
7
|
-
PATH = "path/to/dir"
|
|
8
|
-
ARGS = ["foo", "bar"]
|
|
9
|
-
KWARGS = {"baz": "baz", "qux": "qux"}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
@pytest.fixture
|
|
13
|
-
def make_fs(mocker):
|
|
14
|
-
def _make_fs(async_impl=False, asynchronous=False):
|
|
15
|
-
attrs = {
|
|
16
|
-
"sep": "/",
|
|
17
|
-
"async_impl": async_impl,
|
|
18
|
-
"_strip_protocol": lambda path: path,
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if async_impl:
|
|
22
|
-
attrs["asynchronous"] = asynchronous
|
|
23
|
-
cls = AsyncFileSystem
|
|
24
|
-
else:
|
|
25
|
-
cls = AbstractFileSystem
|
|
26
|
-
|
|
27
|
-
fs = mocker.MagicMock(spec=cls, **attrs)
|
|
28
|
-
|
|
29
|
-
return fs
|
|
30
|
-
|
|
31
|
-
return _make_fs
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
@pytest.fixture(
|
|
35
|
-
params=[
|
|
36
|
-
pytest.param(False, id="sync"),
|
|
37
|
-
pytest.param(True, id="async"),
|
|
38
|
-
]
|
|
39
|
-
)
|
|
40
|
-
def fs(make_fs, request):
|
|
41
|
-
return make_fs(async_impl=request.param)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
@pytest.fixture
|
|
45
|
-
def asyncfs(make_fs):
|
|
46
|
-
return make_fs(async_impl=True, asynchronous=True)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
@pytest.fixture
|
|
50
|
-
def make_dirfs():
|
|
51
|
-
def _make_dirfs(fs, asynchronous=False):
|
|
52
|
-
return DirFileSystem(PATH, fs, asynchronous=asynchronous)
|
|
53
|
-
|
|
54
|
-
return _make_dirfs
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
@pytest.fixture
|
|
58
|
-
def dirfs(make_dirfs, fs):
|
|
59
|
-
return make_dirfs(fs)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
@pytest.fixture
|
|
63
|
-
def adirfs(make_dirfs, asyncfs):
|
|
64
|
-
return make_dirfs(asyncfs, asynchronous=True)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
def test_dirfs(fs, asyncfs):
|
|
68
|
-
DirFileSystem("path", fs)
|
|
69
|
-
DirFileSystem("path", asyncfs, asynchronous=True)
|
|
70
|
-
|
|
71
|
-
with pytest.raises(ValueError):
|
|
72
|
-
DirFileSystem("path", asyncfs)
|
|
73
|
-
|
|
74
|
-
with pytest.raises(ValueError):
|
|
75
|
-
DirFileSystem("path", fs, asynchronous=True)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
@pytest.mark.parametrize(
|
|
79
|
-
"root, rel, full",
|
|
80
|
-
[
|
|
81
|
-
("", "", ""),
|
|
82
|
-
("", "foo", "foo"),
|
|
83
|
-
("root", "", "root"),
|
|
84
|
-
("root", "foo", "root/foo"),
|
|
85
|
-
],
|
|
86
|
-
)
|
|
87
|
-
def test_path(fs, root, rel, full):
|
|
88
|
-
dirfs = DirFileSystem(root, fs)
|
|
89
|
-
assert dirfs._join(rel) == full
|
|
90
|
-
assert dirfs._relpath(full) == rel
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
def test_sep(mocker, dirfs):
|
|
94
|
-
sep = mocker.Mock()
|
|
95
|
-
dirfs.fs.sep = sep
|
|
96
|
-
assert dirfs.sep == sep
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
@pytest.mark.asyncio
|
|
100
|
-
async def test_set_session(mocker, adirfs):
|
|
101
|
-
adirfs.fs.set_session = mocker.AsyncMock()
|
|
102
|
-
assert (
|
|
103
|
-
await adirfs.set_session(*ARGS, **KWARGS) == adirfs.fs.set_session.return_value
|
|
104
|
-
)
|
|
105
|
-
adirfs.fs.set_session.assert_called_once_with(*ARGS, **KWARGS)
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
@pytest.mark.asyncio
|
|
109
|
-
async def test_async_rm_file(adirfs):
|
|
110
|
-
await adirfs._rm_file("file", **KWARGS)
|
|
111
|
-
adirfs.fs._rm_file.assert_called_once_with(f"{PATH}/file", **KWARGS)
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
def test_rm_file(dirfs):
|
|
115
|
-
dirfs.rm_file("file", **KWARGS)
|
|
116
|
-
dirfs.fs.rm_file.assert_called_once_with("path/to/dir/file", **KWARGS)
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
@pytest.mark.asyncio
|
|
120
|
-
async def test_async_rm(adirfs):
|
|
121
|
-
await adirfs._rm("file", *ARGS, **KWARGS)
|
|
122
|
-
adirfs.fs._rm.assert_called_once_with("path/to/dir/file", *ARGS, **KWARGS)
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
def test_rm(dirfs):
|
|
126
|
-
dirfs.rm("file", *ARGS, **KWARGS)
|
|
127
|
-
dirfs.fs.rm.assert_called_once_with("path/to/dir/file", *ARGS, **KWARGS)
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
@pytest.mark.asyncio
|
|
131
|
-
async def test_async_cp_file(adirfs):
|
|
132
|
-
await adirfs._cp_file("one", "two", **KWARGS)
|
|
133
|
-
adirfs.fs._cp_file.assert_called_once_with(f"{PATH}/one", f"{PATH}/two", **KWARGS)
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
def test_cp_file(dirfs):
|
|
137
|
-
dirfs.cp_file("one", "two", **KWARGS)
|
|
138
|
-
dirfs.fs.cp_file.assert_called_once_with(f"{PATH}/one", f"{PATH}/two", **KWARGS)
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
@pytest.mark.asyncio
|
|
142
|
-
async def test_async_copy(adirfs):
|
|
143
|
-
await adirfs._copy("one", "two", *ARGS, **KWARGS)
|
|
144
|
-
adirfs.fs._copy.assert_called_once_with(
|
|
145
|
-
f"{PATH}/one", f"{PATH}/two", *ARGS, **KWARGS
|
|
146
|
-
)
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
def test_copy(dirfs):
|
|
150
|
-
dirfs.copy("one", "two", *ARGS, **KWARGS)
|
|
151
|
-
dirfs.fs.copy.assert_called_once_with(f"{PATH}/one", f"{PATH}/two", *ARGS, **KWARGS)
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
@pytest.mark.asyncio
|
|
155
|
-
async def test_async_pipe(adirfs):
|
|
156
|
-
await adirfs._pipe("file", *ARGS, **KWARGS)
|
|
157
|
-
adirfs.fs._pipe.assert_called_once_with(f"{PATH}/file", *ARGS, **KWARGS)
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
def test_pipe(dirfs):
|
|
161
|
-
dirfs.pipe("file", *ARGS, **KWARGS)
|
|
162
|
-
dirfs.fs.pipe.assert_called_once_with(f"{PATH}/file", *ARGS, **KWARGS)
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
@pytest.mark.asyncio
|
|
166
|
-
async def test_async_pipe_file(adirfs):
|
|
167
|
-
await adirfs._pipe_file("file", *ARGS, **KWARGS)
|
|
168
|
-
adirfs.fs._pipe_file.assert_called_once_with(f"{PATH}/file", *ARGS, **KWARGS)
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
def test_pipe_file(dirfs):
|
|
172
|
-
dirfs.pipe_file("file", *ARGS, **KWARGS)
|
|
173
|
-
dirfs.fs.pipe_file.assert_called_once_with(f"{PATH}/file", *ARGS, **KWARGS)
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
@pytest.mark.asyncio
|
|
177
|
-
async def test_async_cat_file(adirfs):
|
|
178
|
-
assert (
|
|
179
|
-
await adirfs._cat_file("file", *ARGS, **KWARGS)
|
|
180
|
-
== adirfs.fs._cat_file.return_value
|
|
181
|
-
)
|
|
182
|
-
adirfs.fs._cat_file.assert_called_once_with(f"{PATH}/file", *ARGS, **KWARGS)
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
def test_cat_file(dirfs):
|
|
186
|
-
assert dirfs.cat_file("file", *ARGS, **KWARGS) == dirfs.fs.cat_file.return_value
|
|
187
|
-
dirfs.fs.cat_file.assert_called_once_with(f"{PATH}/file", *ARGS, **KWARGS)
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
@pytest.mark.asyncio
|
|
191
|
-
async def test_async_cat(adirfs):
|
|
192
|
-
assert await adirfs._cat("file", *ARGS, **KWARGS) == adirfs.fs._cat.return_value
|
|
193
|
-
adirfs.fs._cat.assert_called_once_with(f"{PATH}/file", *ARGS, **KWARGS)
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
def test_cat(dirfs):
|
|
197
|
-
assert dirfs.cat("file", *ARGS, **KWARGS) == dirfs.fs.cat.return_value
|
|
198
|
-
dirfs.fs.cat.assert_called_once_with(f"{PATH}/file", *ARGS, **KWARGS)
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
@pytest.mark.asyncio
|
|
202
|
-
async def test_async_cat_list(adirfs):
|
|
203
|
-
adirfs.fs._cat.return_value = {f"{PATH}/one": "foo", f"{PATH}/two": "bar"}
|
|
204
|
-
assert await adirfs._cat(["one", "two"], *ARGS, **KWARGS) == {
|
|
205
|
-
"one": "foo",
|
|
206
|
-
"two": "bar",
|
|
207
|
-
}
|
|
208
|
-
adirfs.fs._cat.assert_called_once_with(
|
|
209
|
-
[f"{PATH}/one", f"{PATH}/two"], *ARGS, **KWARGS
|
|
210
|
-
)
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
def test_cat_list(dirfs):
|
|
214
|
-
dirfs.fs.cat.return_value = {f"{PATH}/one": "foo", f"{PATH}/two": "bar"}
|
|
215
|
-
assert dirfs.cat(["one", "two"], *ARGS, **KWARGS) == {"one": "foo", "two": "bar"}
|
|
216
|
-
dirfs.fs.cat.assert_called_once_with(
|
|
217
|
-
[f"{PATH}/one", f"{PATH}/two"], *ARGS, **KWARGS
|
|
218
|
-
)
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
@pytest.mark.asyncio
|
|
222
|
-
async def test_async_put_file(adirfs):
|
|
223
|
-
await adirfs._put_file("local", "file", **KWARGS)
|
|
224
|
-
adirfs.fs._put_file.assert_called_once_with("local", f"{PATH}/file", **KWARGS)
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
def test_put_file(dirfs):
|
|
228
|
-
dirfs.put_file("local", "file", **KWARGS)
|
|
229
|
-
dirfs.fs.put_file.assert_called_once_with("local", f"{PATH}/file", **KWARGS)
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
@pytest.mark.asyncio
|
|
233
|
-
async def test_async_put(adirfs):
|
|
234
|
-
await adirfs._put("local", "file", **KWARGS)
|
|
235
|
-
adirfs.fs._put.assert_called_once_with("local", f"{PATH}/file", **KWARGS)
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
def test_put(dirfs):
|
|
239
|
-
dirfs.put("local", "file", **KWARGS)
|
|
240
|
-
dirfs.fs.put.assert_called_once_with("local", f"{PATH}/file", **KWARGS)
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
@pytest.mark.asyncio
|
|
244
|
-
async def test_async_get_file(adirfs):
|
|
245
|
-
await adirfs._get_file("file", "local", **KWARGS)
|
|
246
|
-
adirfs.fs._get_file.assert_called_once_with(f"{PATH}/file", "local", **KWARGS)
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
def test_get_file(dirfs):
|
|
250
|
-
dirfs.get_file("file", "local", **KWARGS)
|
|
251
|
-
dirfs.fs.get_file.assert_called_once_with(f"{PATH}/file", "local", **KWARGS)
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
@pytest.mark.asyncio
|
|
255
|
-
async def test_async_get(adirfs):
|
|
256
|
-
await adirfs._get("file", "local", **KWARGS)
|
|
257
|
-
adirfs.fs._get.assert_called_once_with(f"{PATH}/file", "local", **KWARGS)
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
def test_get(dirfs):
|
|
261
|
-
dirfs.get("file", "local", **KWARGS)
|
|
262
|
-
dirfs.fs.get.assert_called_once_with(f"{PATH}/file", "local", **KWARGS)
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
@pytest.mark.asyncio
|
|
266
|
-
async def test_async_isfile(adirfs):
|
|
267
|
-
assert await adirfs._isfile("file") == adirfs.fs._isfile.return_value
|
|
268
|
-
adirfs.fs._isfile.assert_called_once_with(f"{PATH}/file")
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
def test_isfile(dirfs):
|
|
272
|
-
assert dirfs.isfile("file") == dirfs.fs.isfile.return_value
|
|
273
|
-
dirfs.fs.isfile.assert_called_once_with(f"{PATH}/file")
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
@pytest.mark.asyncio
|
|
277
|
-
async def test_async_isdir(adirfs):
|
|
278
|
-
assert await adirfs._isdir("file") == adirfs.fs._isdir.return_value
|
|
279
|
-
adirfs.fs._isdir.assert_called_once_with(f"{PATH}/file")
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
def test_isdir(dirfs):
|
|
283
|
-
assert dirfs.isdir("file") == dirfs.fs.isdir.return_value
|
|
284
|
-
dirfs.fs.isdir.assert_called_once_with(f"{PATH}/file")
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
@pytest.mark.asyncio
|
|
288
|
-
async def test_async_size(adirfs):
|
|
289
|
-
assert await adirfs._size("file") == adirfs.fs._size.return_value
|
|
290
|
-
adirfs.fs._size.assert_called_once_with(f"{PATH}/file")
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
def test_size(dirfs):
|
|
294
|
-
assert dirfs.size("file") == dirfs.fs.size.return_value
|
|
295
|
-
dirfs.fs.size.assert_called_once_with(f"{PATH}/file")
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
@pytest.mark.asyncio
|
|
299
|
-
async def test_async_exists(adirfs):
|
|
300
|
-
assert await adirfs._exists("file") == adirfs.fs._exists.return_value
|
|
301
|
-
adirfs.fs._exists.assert_called_once_with(f"{PATH}/file")
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
def test_exists(dirfs):
|
|
305
|
-
assert dirfs.exists("file") == dirfs.fs.exists.return_value
|
|
306
|
-
dirfs.fs.exists.assert_called_once_with(f"{PATH}/file")
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
@pytest.mark.asyncio
|
|
310
|
-
async def test_async_info(adirfs):
|
|
311
|
-
assert await adirfs._info("file", **KWARGS) == adirfs.fs._info.return_value
|
|
312
|
-
adirfs.fs._info.assert_called_once_with(f"{PATH}/file", **KWARGS)
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
def test_info(dirfs):
|
|
316
|
-
assert dirfs.info("file", **KWARGS) == dirfs.fs.info.return_value
|
|
317
|
-
dirfs.fs.info.assert_called_once_with(f"{PATH}/file", **KWARGS)
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
@pytest.mark.asyncio
|
|
321
|
-
async def test_async_ls(adirfs):
|
|
322
|
-
adirfs.fs._ls.return_value = [f"{PATH}/file"]
|
|
323
|
-
assert await adirfs._ls("file", detail=False, **KWARGS) == ["file"]
|
|
324
|
-
adirfs.fs._ls.assert_called_once_with(f"{PATH}/file", detail=False, **KWARGS)
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
def test_ls(dirfs):
|
|
328
|
-
dirfs.fs.ls.return_value = [f"{PATH}/file"]
|
|
329
|
-
assert dirfs.ls("file", detail=False, **KWARGS) == ["file"]
|
|
330
|
-
dirfs.fs.ls.assert_called_once_with(f"{PATH}/file", detail=False, **KWARGS)
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
@pytest.mark.asyncio
|
|
334
|
-
async def test_async_ls_detail(adirfs):
|
|
335
|
-
adirfs.fs._ls.return_value = [{"name": f"{PATH}/file", "foo": "bar"}]
|
|
336
|
-
assert await adirfs._ls("file", detail=True, **KWARGS) == [
|
|
337
|
-
{"name": "file", "foo": "bar"}
|
|
338
|
-
]
|
|
339
|
-
adirfs.fs._ls.assert_called_once_with(f"{PATH}/file", detail=True, **KWARGS)
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
def test_ls_detail(dirfs):
|
|
343
|
-
dirfs.fs.ls.return_value = [{"name": f"{PATH}/file", "foo": "bar"}]
|
|
344
|
-
assert dirfs.ls("file", detail=True, **KWARGS) == [{"name": "file", "foo": "bar"}]
|
|
345
|
-
dirfs.fs.ls.assert_called_once_with(f"{PATH}/file", detail=True, **KWARGS)
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
@pytest.mark.asyncio
|
|
349
|
-
async def test_async_walk(adirfs, mocker):
|
|
350
|
-
async def _walk(path, *args, **kwargs):
|
|
351
|
-
yield (f"{PATH}/root", ["foo", "bar"], ["baz", "qux"])
|
|
352
|
-
|
|
353
|
-
adirfs.fs._walk = mocker.MagicMock()
|
|
354
|
-
adirfs.fs._walk.side_effect = _walk
|
|
355
|
-
|
|
356
|
-
actual = []
|
|
357
|
-
async for entry in adirfs._walk("root", *ARGS, **KWARGS):
|
|
358
|
-
actual.append(entry) # noqa: PERF402
|
|
359
|
-
assert actual == [("root", ["foo", "bar"], ["baz", "qux"])]
|
|
360
|
-
adirfs.fs._walk.assert_called_once_with(f"{PATH}/root", *ARGS, **KWARGS)
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
def test_walk(dirfs):
|
|
364
|
-
dirfs.fs.walk.return_value = iter(
|
|
365
|
-
[(f"{PATH}/root", ["foo", "bar"], ["baz", "qux"])]
|
|
366
|
-
)
|
|
367
|
-
assert list(dirfs.walk("root", *ARGS, **KWARGS)) == [
|
|
368
|
-
("root", ["foo", "bar"], ["baz", "qux"])
|
|
369
|
-
]
|
|
370
|
-
dirfs.fs.walk.assert_called_once_with(f"{PATH}/root", *ARGS, **KWARGS)
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
@pytest.mark.asyncio
|
|
374
|
-
async def test_async_glob(adirfs):
|
|
375
|
-
adirfs.fs._glob.return_value = [f"{PATH}/one", f"{PATH}/two"]
|
|
376
|
-
assert await adirfs._glob("*", **KWARGS) == ["one", "two"]
|
|
377
|
-
adirfs.fs._glob.assert_called_once_with(f"{PATH}/*", **KWARGS)
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
def test_glob(dirfs):
|
|
381
|
-
dirfs.fs.glob.return_value = [f"{PATH}/one", f"{PATH}/two"]
|
|
382
|
-
assert dirfs.glob("*", **KWARGS) == ["one", "two"]
|
|
383
|
-
dirfs.fs.glob.assert_called_once_with(f"{PATH}/*", **KWARGS)
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
def test_glob_with_protocol(dirfs):
|
|
387
|
-
dirfs.fs.glob.return_value = [f"{PATH}/one", f"{PATH}/two"]
|
|
388
|
-
assert dirfs.glob("dir://*", **KWARGS) == ["one", "two"]
|
|
389
|
-
dirfs.fs.glob.assert_called_once_with(f"{PATH}/*", **KWARGS)
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
@pytest.mark.asyncio
|
|
393
|
-
async def test_async_glob_detail(adirfs):
|
|
394
|
-
adirfs.fs._glob.return_value = {
|
|
395
|
-
f"{PATH}/one": {"foo": "bar"},
|
|
396
|
-
f"{PATH}/two": {"baz": "qux"},
|
|
397
|
-
}
|
|
398
|
-
assert await adirfs._glob("*", detail=True, **KWARGS) == {
|
|
399
|
-
"one": {"foo": "bar"},
|
|
400
|
-
"two": {"baz": "qux"},
|
|
401
|
-
}
|
|
402
|
-
adirfs.fs._glob.assert_called_once_with(f"{PATH}/*", detail=True, **KWARGS)
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
def test_glob_detail(dirfs):
|
|
406
|
-
dirfs.fs.glob.return_value = {
|
|
407
|
-
f"{PATH}/one": {"foo": "bar"},
|
|
408
|
-
f"{PATH}/two": {"baz": "qux"},
|
|
409
|
-
}
|
|
410
|
-
assert dirfs.glob("*", detail=True, **KWARGS) == {
|
|
411
|
-
"one": {"foo": "bar"},
|
|
412
|
-
"two": {"baz": "qux"},
|
|
413
|
-
}
|
|
414
|
-
dirfs.fs.glob.assert_called_once_with(f"{PATH}/*", detail=True, **KWARGS)
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
@pytest.mark.asyncio
|
|
418
|
-
async def test_async_du(adirfs):
|
|
419
|
-
adirfs.fs._du.return_value = 1234
|
|
420
|
-
assert await adirfs._du("file", *ARGS, **KWARGS) == 1234
|
|
421
|
-
adirfs.fs._du.assert_called_once_with(f"{PATH}/file", *ARGS, **KWARGS)
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
def test_du(dirfs):
|
|
425
|
-
dirfs.fs.du.return_value = 1234
|
|
426
|
-
assert dirfs.du("file", *ARGS, **KWARGS) == 1234
|
|
427
|
-
dirfs.fs.du.assert_called_once_with(f"{PATH}/file", *ARGS, **KWARGS)
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
@pytest.mark.asyncio
|
|
431
|
-
async def test_async_du_granular(adirfs):
|
|
432
|
-
adirfs.fs._du.return_value = {f"{PATH}/dir/one": 1, f"{PATH}/dir/two": 2}
|
|
433
|
-
assert await adirfs._du("dir", *ARGS, total=False, **KWARGS) == {
|
|
434
|
-
"dir/one": 1,
|
|
435
|
-
"dir/two": 2,
|
|
436
|
-
}
|
|
437
|
-
adirfs.fs._du.assert_called_once_with(f"{PATH}/dir", *ARGS, total=False, **KWARGS)
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
def test_du_granular(dirfs):
|
|
441
|
-
dirfs.fs.du.return_value = {f"{PATH}/dir/one": 1, f"{PATH}/dir/two": 2}
|
|
442
|
-
assert dirfs.du("dir", *ARGS, total=False, **KWARGS) == {"dir/one": 1, "dir/two": 2}
|
|
443
|
-
dirfs.fs.du.assert_called_once_with(f"{PATH}/dir", *ARGS, total=False, **KWARGS)
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
@pytest.mark.asyncio
|
|
447
|
-
async def test_async_find(adirfs):
|
|
448
|
-
adirfs.fs._find.return_value = [f"{PATH}/dir/one", f"{PATH}/dir/two"]
|
|
449
|
-
assert await adirfs._find("dir", *ARGS, **KWARGS) == ["dir/one", "dir/two"]
|
|
450
|
-
adirfs.fs._find.assert_called_once_with(f"{PATH}/dir", *ARGS, **KWARGS)
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
def test_find(dirfs):
|
|
454
|
-
dirfs.fs.find.return_value = [f"{PATH}/dir/one", f"{PATH}/dir/two"]
|
|
455
|
-
assert dirfs.find("dir", *ARGS, **KWARGS) == ["dir/one", "dir/two"]
|
|
456
|
-
dirfs.fs.find.assert_called_once_with(f"{PATH}/dir", *ARGS, **KWARGS)
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
@pytest.mark.asyncio
|
|
460
|
-
async def test_async_find_detail(adirfs):
|
|
461
|
-
adirfs.fs._find.return_value = {
|
|
462
|
-
f"{PATH}/dir/one": {"foo": "bar"},
|
|
463
|
-
f"{PATH}/dir/two": {"baz": "qux"},
|
|
464
|
-
}
|
|
465
|
-
assert await adirfs._find("dir", *ARGS, detail=True, **KWARGS) == {
|
|
466
|
-
"dir/one": {"foo": "bar"},
|
|
467
|
-
"dir/two": {"baz": "qux"},
|
|
468
|
-
}
|
|
469
|
-
adirfs.fs._find.assert_called_once_with(f"{PATH}/dir", *ARGS, detail=True, **KWARGS)
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
def test_find_detail(dirfs):
|
|
473
|
-
dirfs.fs.find.return_value = {
|
|
474
|
-
f"{PATH}/dir/one": {"foo": "bar"},
|
|
475
|
-
f"{PATH}/dir/two": {"baz": "qux"},
|
|
476
|
-
}
|
|
477
|
-
assert dirfs.find("dir", *ARGS, detail=True, **KWARGS) == {
|
|
478
|
-
"dir/one": {"foo": "bar"},
|
|
479
|
-
"dir/two": {"baz": "qux"},
|
|
480
|
-
}
|
|
481
|
-
dirfs.fs.find.assert_called_once_with(f"{PATH}/dir", *ARGS, detail=True, **KWARGS)
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
@pytest.mark.asyncio
|
|
485
|
-
async def test_async_expand_path(adirfs):
|
|
486
|
-
adirfs.fs._expand_path.return_value = [f"{PATH}/file"]
|
|
487
|
-
assert await adirfs._expand_path("*", *ARGS, **KWARGS) == ["file"]
|
|
488
|
-
adirfs.fs._expand_path.assert_called_once_with(f"{PATH}/*", *ARGS, **KWARGS)
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
def test_expand_path(dirfs):
|
|
492
|
-
dirfs.fs.expand_path.return_value = [f"{PATH}/file"]
|
|
493
|
-
assert dirfs.expand_path("*", *ARGS, **KWARGS) == ["file"]
|
|
494
|
-
dirfs.fs.expand_path.assert_called_once_with(f"{PATH}/*", *ARGS, **KWARGS)
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
@pytest.mark.asyncio
|
|
498
|
-
async def test_async_expand_path_list(adirfs):
|
|
499
|
-
adirfs.fs._expand_path.return_value = [f"{PATH}/1file", f"{PATH}/2file"]
|
|
500
|
-
assert await adirfs._expand_path(["1*", "2*"], *ARGS, **KWARGS) == [
|
|
501
|
-
"1file",
|
|
502
|
-
"2file",
|
|
503
|
-
]
|
|
504
|
-
adirfs.fs._expand_path.assert_called_once_with(
|
|
505
|
-
[f"{PATH}/1*", f"{PATH}/2*"], *ARGS, **KWARGS
|
|
506
|
-
)
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
def test_expand_path_list(dirfs):
|
|
510
|
-
dirfs.fs.expand_path.return_value = [f"{PATH}/1file", f"{PATH}/2file"]
|
|
511
|
-
assert dirfs.expand_path(["1*", "2*"], *ARGS, **KWARGS) == ["1file", "2file"]
|
|
512
|
-
dirfs.fs.expand_path.assert_called_once_with(
|
|
513
|
-
[f"{PATH}/1*", f"{PATH}/2*"], *ARGS, **KWARGS
|
|
514
|
-
)
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
@pytest.mark.asyncio
|
|
518
|
-
async def test_async_mkdir(adirfs):
|
|
519
|
-
await adirfs._mkdir("dir", *ARGS, **KWARGS)
|
|
520
|
-
adirfs.fs._mkdir.assert_called_once_with(f"{PATH}/dir", *ARGS, **KWARGS)
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
def test_mkdir(dirfs):
|
|
524
|
-
dirfs.mkdir("dir", *ARGS, **KWARGS)
|
|
525
|
-
dirfs.fs.mkdir.assert_called_once_with(f"{PATH}/dir", *ARGS, **KWARGS)
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
@pytest.mark.asyncio
|
|
529
|
-
async def test_async_makedirs(adirfs):
|
|
530
|
-
await adirfs._makedirs("dir", *ARGS, **KWARGS)
|
|
531
|
-
adirfs.fs._makedirs.assert_called_once_with(f"{PATH}/dir", *ARGS, **KWARGS)
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
def test_makedirs(dirfs):
|
|
535
|
-
dirfs.makedirs("dir", *ARGS, **KWARGS)
|
|
536
|
-
dirfs.fs.makedirs.assert_called_once_with(f"{PATH}/dir", *ARGS, **KWARGS)
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
def test_rmdir(mocker, dirfs):
|
|
540
|
-
dirfs.fs.rmdir = mocker.Mock()
|
|
541
|
-
dirfs.rmdir("dir")
|
|
542
|
-
dirfs.fs.rmdir.assert_called_once_with(f"{PATH}/dir")
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
def test_mv(mocker, dirfs):
|
|
546
|
-
dirfs.fs.mv = mocker.Mock()
|
|
547
|
-
dirfs.mv("one", "two", **KWARGS)
|
|
548
|
-
dirfs.fs.mv.assert_called_once_with(f"{PATH}/one", f"{PATH}/two", **KWARGS)
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
def test_touch(mocker, dirfs):
|
|
552
|
-
dirfs.fs.touch = mocker.Mock()
|
|
553
|
-
dirfs.touch("file", **KWARGS)
|
|
554
|
-
dirfs.fs.touch.assert_called_once_with(f"{PATH}/file", **KWARGS)
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
def test_created(mocker, dirfs):
|
|
558
|
-
dirfs.fs.created = mocker.Mock(return_value="date")
|
|
559
|
-
assert dirfs.created("file") == "date"
|
|
560
|
-
dirfs.fs.created.assert_called_once_with(f"{PATH}/file")
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
def test_modified(mocker, dirfs):
|
|
564
|
-
dirfs.fs.modified = mocker.Mock(return_value="date")
|
|
565
|
-
assert dirfs.modified("file") == "date"
|
|
566
|
-
dirfs.fs.modified.assert_called_once_with(f"{PATH}/file")
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
def test_sign(mocker, dirfs):
|
|
570
|
-
dirfs.fs.sign = mocker.Mock(return_value="url")
|
|
571
|
-
assert dirfs.sign("file", *ARGS, **KWARGS) == "url"
|
|
572
|
-
dirfs.fs.sign.assert_called_once_with(f"{PATH}/file", *ARGS, **KWARGS)
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
def test_open(mocker, dirfs):
|
|
576
|
-
dirfs.fs.open = mocker.Mock()
|
|
577
|
-
assert dirfs.open("file", *ARGS, **KWARGS) == dirfs.fs.open.return_value
|
|
578
|
-
dirfs.fs.open.assert_called_once_with(f"{PATH}/file", *ARGS, **KWARGS)
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
def test_from_url(m):
|
|
582
|
-
from fsspec.core import url_to_fs
|
|
583
|
-
|
|
584
|
-
m.pipe("inner/file", b"data")
|
|
585
|
-
fs, _ = url_to_fs("dir::memory://inner")
|
|
586
|
-
assert fs.ls("", False) == ["file"]
|
|
587
|
-
assert fs.ls("", True)[0]["name"] == "file"
|
|
588
|
-
assert fs.cat("file") == b"data"
|