Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardfeng-db committed Nov 16, 2023
1 parent cf041bf commit 80e42ba
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions tests/integration/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,43 +212,43 @@ def create_volume(w, catalog, schema, volume):
return ResourceWithCleanup(lambda: w.volumes.delete(res.full_name))


# def test_files_api_upload_download(ucws, random):
# w = ucws
# schema = 'filesit-' + random()
# volume = 'filesit-' + random()
# with ResourceWithCleanup.create_schema(w, 'main', schema):
# with ResourceWithCleanup.create_volume(w, 'main', schema, volume):
# f = io.BytesIO(b"some text data")
# target_file = f'/Volumes/main/{schema}/{volume}/filesit-{random()}.txt'
# w.files.upload(target_file, f)
#
# res = w.files.get_status(target_file)
# assert not res.is_dir
#
# with w.files.download(target_file).contents as f:
# assert f.read() == b"some text data"
#
# w.files.delete(target_file)
#
#
# def test_files_api_read_twice_from_one_download(ucws, random):
# w = ucws
# schema = 'filesit-' + random()
# volume = 'filesit-' + random()
# with ResourceWithCleanup.create_schema(w, 'main', schema):
# with ResourceWithCleanup.create_volume(w, 'main', schema, volume):
# f = io.BytesIO(b"some text data")
# target_file = f'/Volumes/main/{schema}/{volume}/filesit-{random()}.txt'
# w.files.upload(target_file, f)
#
# res = w.files.download(target_file).contents
#
# with res:
# assert res.read() == b"some text data"
#
# with pytest.raises(ValueError):
# with res:
# res.read()
def test_files_api_upload_download(ucws, random):
w = ucws
schema = 'filesit-' + random()
volume = 'filesit-' + random()
with ResourceWithCleanup.create_schema(w, 'main', schema):
with ResourceWithCleanup.create_volume(w, 'main', schema, volume):
f = io.BytesIO(b"some text data")
target_file = f'/Volumes/main/{schema}/{volume}/filesit-{random()}.txt'
w.files.upload(target_file, f)

res = w.files.get_status(target_file)
assert not res.is_dir

with w.files.download(target_file).contents as f:
assert f.read() == b"some text data"

w.files.delete(target_file)


def test_files_api_read_twice_from_one_download(ucws, random):
w = ucws
schema = 'filesit-' + random()
volume = 'filesit-' + random()
with ResourceWithCleanup.create_schema(w, 'main', schema):
with ResourceWithCleanup.create_volume(w, 'main', schema, volume):
f = io.BytesIO(b"some text data")
target_file = f'/Volumes/main/{schema}/{volume}/filesit-{random()}.txt'
w.files.upload(target_file, f)

res = w.files.download(target_file).contents

with res:
assert res.read() == b"some text data"

with pytest.raises(ValueError):
with res:
res.read()


@pytest.mark.benchmark
Expand Down

0 comments on commit 80e42ba

Please sign in to comment.