Skip to content

Commit c08ed2c

Browse files
committed
Add test
1 parent 214fa55 commit c08ed2c

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

s3fs/tests/test_s3fs.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,6 +1544,35 @@ def test_touch(s3):
15441544
assert s3.size(fn) == 4
15451545

15461546

1547+
@pytest.mark.skipif(py35, reason="no versions on old moto for py36")
1548+
def test_touch_versions(s3):
1549+
versioned_file = versioned_bucket_name + "/versioned_file"
1550+
s3 = S3FileSystem(
1551+
anon=False, version_aware=True, client_kwargs={"endpoint_url": endpoint_uri}
1552+
)
1553+
returned_versions = []
1554+
with s3.open(versioned_file, "wb") as fo:
1555+
fo.write(b"1")
1556+
returned_versions.append(fo.version_id)
1557+
with s3.open(versioned_file, "wb") as fo:
1558+
fo.write(b"")
1559+
returned_versions.append(fo.version_id)
1560+
assert s3.isfile(versioned_file)
1561+
versions = s3.object_version_info(versioned_file)
1562+
version_ids = [version["VersionId"] for version in versions]
1563+
assert len(version_ids) == 2
1564+
1565+
with s3.open(versioned_file) as fo:
1566+
assert fo.version_id == version_ids[1]
1567+
assert fo.version_id == returned_versions[1]
1568+
assert fo.read() == b""
1569+
1570+
with s3.open(versioned_file, version_id=version_ids[0]) as fo:
1571+
assert fo.version_id == version_ids[0]
1572+
assert fo.version_id == returned_versions[0]
1573+
assert fo.read() == b"1"
1574+
1575+
15471576
def test_cat_missing(s3):
15481577
fn0 = test_bucket_name + "/file0"
15491578
fn1 = test_bucket_name + "/file1"

0 commit comments

Comments
 (0)