Skip to content

Commit

Permalink
Run test cases on hns
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghua committed Nov 5, 2024
1 parent 7ba7afe commit 51be251
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
Binary file added .DS_Store
Binary file not shown.
4 changes: 4 additions & 0 deletions tosfs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,10 @@ def ls_iterate(

path = self._strip_protocol(path)
bucket, key, _ = self._split_path(path)

if recursive and self._is_hns_bucket(bucket):
raise ValueError("Recursive listing is not supported for HNS bucket.")

prefix = key.lstrip("/") + "/" if key else ""
continuation_token = ""
is_truncated = True
Expand Down
29 changes: 16 additions & 13 deletions tosfs/tests/test_tosfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,22 @@ def test_ls_iterate(
assert len(result) == len([dir_name, another_dir_name])

# Test list recursively
expected = [
f"{bucket}/{temporary_workspace}/{dir_name}",
f"{bucket}/{temporary_workspace}/{dir_name}/{file_name}",
f"{bucket}/{temporary_workspace}/{dir_name}/{sub_dir_name}",
f"{bucket}/{temporary_workspace}/{dir_name}/{sub_dir_name}/{sub_file_name}",
f"{bucket}/{temporary_workspace}/{another_dir_name}",
]
result = [
item
for batch in tosfs.ls_iterate(f"{bucket}/{temporary_workspace}", recursive=True)
for item in batch
]
assert sorted(result) == sorted(expected)
if tosfs._is_fns_bucket(bucket):
expected = [
f"{bucket}/{temporary_workspace}/{dir_name}",
f"{bucket}/{temporary_workspace}/{dir_name}/{file_name}",
f"{bucket}/{temporary_workspace}/{dir_name}/{sub_dir_name}",
f"{bucket}/{temporary_workspace}/{dir_name}/{sub_dir_name}/{sub_file_name}",
f"{bucket}/{temporary_workspace}/{another_dir_name}",
]
result = [
item
for batch in tosfs.ls_iterate(
f"{bucket}/{temporary_workspace}", recursive=True
)
for item in batch
]
assert sorted(result) == sorted(expected)


def test_inner_rm(tosfs: TosFileSystem, bucket: str, temporary_workspace: str) -> None:
Expand Down

0 comments on commit 51be251

Please sign in to comment.