forked from pool/python-gcsfs
- async operations via aiohttp - Add avoid_network_tests.patch to skip over network requiring test (gh#dask/gcsfs#292). OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-gcsfs?expand=0&rev=7
461 lines
11 KiB
Diff
461 lines
11 KiB
Diff
---
|
|
gcsfs/tests/test_core.py | 44 ++++++++++++++++++++++++++++++++++++++++
|
|
gcsfs/tests/test_mapping.py | 10 +++++++++
|
|
setup.cfg | 6 -----
|
|
setup.cfg | 3 ++
|
|
4 files changed, 57 insertions(+), 6 deletions(-)
|
|
|
|
--- a/gcsfs/tests/test_mapping.py
|
|
+++ b/gcsfs/tests/test_mapping.py
|
|
@@ -15,6 +15,7 @@ def test_api():
|
|
assert "mapping" in dir(gcsfs)
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_map_simple():
|
|
with gcs_maker() as gcs:
|
|
@@ -26,6 +27,7 @@ def test_map_simple():
|
|
assert list(d.items()) == []
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_map_default_gcsfilesystem():
|
|
with gcs_maker() as gcs:
|
|
@@ -33,6 +35,7 @@ def test_map_default_gcsfilesystem():
|
|
assert d.fs is gcs
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_map_errors():
|
|
with gcs_maker() as gcs:
|
|
@@ -69,6 +72,7 @@ def test_map_with_data():
|
|
assert list(d) == []
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_map_complex_keys():
|
|
with gcs_maker() as gcs:
|
|
@@ -87,6 +91,7 @@ def test_map_complex_keys():
|
|
assert ("x", 1, 2) in d
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_map_clear_empty():
|
|
with gcs_maker() as gcs:
|
|
@@ -100,6 +105,7 @@ def test_map_clear_empty():
|
|
assert list(d) == []
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_map_pickle():
|
|
with gcs_maker() as gcs:
|
|
@@ -114,6 +120,7 @@ def test_map_pickle():
|
|
assert d2["x"] == b"1"
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_map_array():
|
|
with gcs_maker() as gcs:
|
|
@@ -125,6 +132,7 @@ def test_map_array():
|
|
assert d["x"] == b"A" * 1000
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_map_bytearray():
|
|
with gcs_maker() as gcs:
|
|
@@ -134,6 +142,7 @@ def test_map_bytearray():
|
|
assert d["x"] == b"123"
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_new_bucket():
|
|
with gcs_maker() as gcs:
|
|
@@ -156,6 +165,7 @@ def test_new_bucket():
|
|
gcs.rmdir(new_bucket)
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_map_pickle():
|
|
import pickle
|
|
--- a/setup.cfg
|
|
+++ b/setup.cfg
|
|
@@ -27,3 +27,6 @@ max-line-length = 120
|
|
tag_build =
|
|
tag_date = 0
|
|
|
|
+[tool:pytest]
|
|
+markers =
|
|
+ network: marks tests which require network connection
|
|
--- a/gcsfs/tests/test_core.py
|
|
+++ b/gcsfs/tests/test_core.py
|
|
@@ -63,6 +63,7 @@ def test_many_connect():
|
|
pool.join()
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_simple_upload():
|
|
with gcs_maker() as gcs:
|
|
@@ -115,6 +116,7 @@ def test_multi_upload():
|
|
assert gcs.info(fn)["contentType"] == "application/octet-stream"
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_info():
|
|
with gcs_maker() as gcs:
|
|
@@ -122,6 +124,7 @@ def test_info():
|
|
assert gcs.info(a) == gcs.ls(a, detail=True)[0]
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_ls2():
|
|
with gcs_maker() as gcs:
|
|
@@ -133,6 +136,7 @@ def test_ls2():
|
|
assert fn in gcs.ls(TEST_BUCKET + "/test")
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_pickle():
|
|
import pickle
|
|
@@ -158,6 +162,7 @@ def test_pickle():
|
|
assert gcs.ls(TEST_BUCKET) == gcs2.ls(TEST_BUCKET)
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_ls_touch():
|
|
with gcs_maker() as gcs:
|
|
@@ -173,6 +178,7 @@ def test_ls_touch():
|
|
assert set(d["name"] for d in L_d) == set([a, b])
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_rm():
|
|
with gcs_maker() as gcs:
|
|
@@ -188,6 +194,7 @@ def test_rm():
|
|
gcs.rm("nonexistent")
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_rm_batch():
|
|
with gcs_maker() as gcs:
|
|
@@ -200,6 +207,7 @@ def test_rm_batch():
|
|
assert b not in gcs.find(TEST_BUCKET)
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_rm_recursive():
|
|
files = ["/a", "/a/b", "/a/c"]
|
|
@@ -210,6 +218,7 @@ def test_rm_recursive():
|
|
assert not gcs.exists(TEST_BUCKET + files[-1])
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_file_access():
|
|
with gcs_maker() as gcs:
|
|
@@ -223,6 +232,7 @@ def test_file_access():
|
|
assert gcs.tail(fn, 10000) == data
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_file_info():
|
|
with gcs_maker() as gcs:
|
|
@@ -238,6 +248,7 @@ def test_file_info():
|
|
gcs.info(fn + "another")
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_du():
|
|
with gcs_maker(True) as gcs:
|
|
@@ -250,6 +261,7 @@ def test_du():
|
|
)
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_ls():
|
|
with gcs_maker(True) as gcs:
|
|
@@ -261,6 +273,7 @@ def test_ls():
|
|
assert fn in gcs.ls(TEST_BUCKET + "/nested")
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_ls_detail():
|
|
with gcs_maker(True) as gcs:
|
|
@@ -268,6 +281,7 @@ def test_ls_detail():
|
|
assert all(isinstance(item, dict) for item in L)
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_gcs_glob():
|
|
with gcs_maker(True) as gcs:
|
|
@@ -286,6 +300,7 @@ def test_gcs_glob():
|
|
)
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_read_keys_from_bucket():
|
|
with gcs_maker(True) as gcs:
|
|
@@ -300,6 +315,7 @@ def test_read_keys_from_bucket():
|
|
)
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_url():
|
|
with gcs_maker(True) as gcs:
|
|
@@ -311,6 +327,7 @@ def test_url():
|
|
assert "http" in f.url()
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_seek():
|
|
with gcs_maker(True) as gcs:
|
|
@@ -340,6 +357,7 @@ def test_seek():
|
|
assert f.seek(i) == i
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_bad_open():
|
|
with gcs_maker() as gcs:
|
|
@@ -347,6 +365,7 @@ def test_bad_open():
|
|
gcs.open("")
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_copy():
|
|
with gcs_maker(True) as gcs:
|
|
@@ -355,6 +374,7 @@ def test_copy():
|
|
assert gcs.cat(fn) == gcs.cat(fn + "2")
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_move():
|
|
with gcs_maker(True) as gcs:
|
|
@@ -414,6 +434,7 @@ def test_get_put_recursive(protocol):
|
|
)
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_errors():
|
|
with gcs_maker() as gcs:
|
|
@@ -451,6 +472,7 @@ def test_errors():
|
|
assert "bucket" in str(e)
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_read_small():
|
|
with gcs_maker(True) as gcs:
|
|
@@ -467,6 +489,7 @@ def test_read_small():
|
|
assert len(f.cache.cache) < len(out)
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_seek_delimiter():
|
|
with gcs_maker(True) as gcs:
|
|
@@ -486,6 +509,7 @@ def test_seek_delimiter():
|
|
assert f.tell() == ind + 1
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_read_block():
|
|
with gcs_maker(True) as gcs:
|
|
@@ -504,6 +528,7 @@ def test_read_block():
|
|
assert gcs.read_block(path, 5, None) == gcs.read_block(path, 5, 1000)
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_flush():
|
|
with gcs_maker() as gcs:
|
|
@@ -524,6 +549,7 @@ def test_flush():
|
|
wo.write(b"abc")
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_write_fails():
|
|
with gcs_maker() as gcs:
|
|
@@ -555,6 +581,7 @@ def text_mode():
|
|
assert f.read() == text
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_write_blocks():
|
|
with gcs_maker() as gcs:
|
|
@@ -568,6 +595,7 @@ def test_write_blocks():
|
|
assert gcs.info(TEST_BUCKET + "/temp")["size"] == 300000
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_write_blocks2():
|
|
with gcs_maker() as gcs:
|
|
@@ -578,6 +606,7 @@ def test_write_blocks2():
|
|
assert gcs.info(TEST_BUCKET + "/temp1")["size"] == 2 ** 18 + 1
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_readline():
|
|
with gcs_maker(True) as gcs:
|
|
@@ -591,6 +620,7 @@ def test_readline():
|
|
assert result == expected
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_readline_from_cache():
|
|
with gcs_maker() as gcs:
|
|
@@ -615,6 +645,7 @@ def test_readline_from_cache():
|
|
assert f.cache.cache == data
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_readline_empty():
|
|
with gcs_maker() as gcs:
|
|
@@ -626,6 +657,7 @@ def test_readline_empty():
|
|
assert result == data
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_readline_blocksize():
|
|
with gcs_maker() as gcs:
|
|
@@ -646,6 +678,7 @@ def test_readline_blocksize():
|
|
assert result == expected
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_next():
|
|
with gcs_maker(True) as gcs:
|
|
@@ -655,6 +688,7 @@ def test_next():
|
|
assert result == expected
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_iterable():
|
|
with gcs_maker() as gcs:
|
|
@@ -678,6 +712,7 @@ def test_iterable():
|
|
assert b"".join(out) == data
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_readable():
|
|
with gcs_maker() as gcs:
|
|
@@ -688,6 +723,7 @@ def test_readable():
|
|
assert f.readable()
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_seekable():
|
|
with gcs_maker() as gcs:
|
|
@@ -698,6 +734,7 @@ def test_seekable():
|
|
assert f.seekable()
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_writable():
|
|
with gcs_maker() as gcs:
|
|
@@ -708,6 +745,7 @@ def test_writable():
|
|
assert not f.writable()
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_merge():
|
|
with gcs_maker() as gcs:
|
|
@@ -720,6 +758,7 @@ def test_merge():
|
|
assert gcs.info(TEST_BUCKET + "/joined")["size"] == 20
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_bigger_than_block_read():
|
|
with gcs_maker(True) as gcs:
|
|
@@ -733,6 +772,7 @@ def test_bigger_than_block_read():
|
|
assert b"".join(out) == csv_files["2014-01-01.csv"]
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_current():
|
|
with gcs_maker() as gcs:
|
|
@@ -741,6 +781,7 @@ def test_current():
|
|
assert gcs2.session is gcs.session
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_array():
|
|
with gcs_maker() as gcs:
|
|
@@ -756,6 +797,7 @@ def test_array():
|
|
assert out == b"A" * 1000
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_attrs():
|
|
with gcs_maker() as gcs:
|
|
@@ -778,6 +820,7 @@ def test_attrs():
|
|
assert gcs.getxattr(a, "something") == "not"
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_request_user_project():
|
|
with gcs_maker():
|
|
@@ -797,6 +840,7 @@ def test_request_user_project():
|
|
assert result["userProject"] == [TEST_PROJECT]
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_request_user_project_string():
|
|
with gcs_maker():
|
|
@@ -819,6 +863,7 @@ def test_request_user_project_string():
|
|
assert result["userProject"] == [TEST_PROJECT]
|
|
|
|
|
|
+@pytest.mark.network
|
|
@my_vcr.use_cassette(match=["all"])
|
|
def test_request_header():
|
|
with gcs_maker():
|