Skip to content

Commit

Permalink
Disable special char (#) for hns
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghua committed Nov 11, 2024
1 parent 26c0458 commit fcf105c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 37 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci_hns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@ jobs:
echo "TOSFS_LOGGING_LEVEL=${{ vars.TOSFS_LOGGING_LEVEL }}" >> $GITHUB_ENV
echo "TOS_SDK_LOGGING_LEVEL=${{ vars.TOS_SDK_LOGGING_LEVEL }}" >> $GITHUB_ENV
echo "TOS_BUCKET=${{ matrix.bucket-name }}" >> $GITHUB_ENV
echo "HNS_DISABLE_SPECIAL_CHAR_TESTS=${{ vars.HNS_DISABLE_SPECIAL_CHAR_TESTS }}" >> $GITHUB_ENV
- name: Run tests
run: make test
78 changes: 41 additions & 37 deletions tosfs/tests/test_tosfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,43 +427,47 @@ def test_put(tosfs: TosFileSystem, bucket: str, temporary_workspace: str):
) as file:
assert file.read() == "hello world"

with tempfile.TemporaryDirectory() as local_temp_dir:
dir_2 = f"{local_temp_dir}/生技??174号文/"
dir_3 = f"{local_temp_dir}/生技**174号文/"
dir_4 = f"{local_temp_dir}/生技_=+&^%#174号文/"
os.makedirs(dir_2)
os.makedirs(dir_3)
os.makedirs(dir_4)
with open(f"{dir_2}/test.txt", "w") as f:
f.write("hello world")
tosfs.put(
local_temp_dir,
f"{bucket}/{temporary_workspace}",
recursive=True,
disable_glob=True,
)
assert tosfs.exists(
f"{bucket}/{temporary_workspace}/{os.path.basename(local_temp_dir)}"
f"/生技??174号文/"
)
assert tosfs.exists(
f"{bucket}/{temporary_workspace}/{os.path.basename(local_temp_dir)}"
f"/生技??174号文/test.txt"
)
assert tosfs.exists(
f"{bucket}/{temporary_workspace}/{os.path.basename(local_temp_dir)}"
f"/生技**174号文/"
)
assert tosfs.exists(
f"{bucket}/{temporary_workspace}/{os.path.basename(local_temp_dir)}"
f"/生技_=+&^%#174号文/"
)
with tosfs.open(
f"{bucket}/{temporary_workspace}/"
f"{os.path.basename(local_temp_dir)}/生技??174号文/test.txt",
mode="r",
) as file:
assert file.read() == "hello world"
if (
tosfs._is_hns_bucket(bucket)
and os.environ.get("HNS_DISABLE_SPECIAL_CHAR_TESTS") == "true"
):
with tempfile.TemporaryDirectory() as local_temp_dir:
dir_2 = f"{local_temp_dir}/生技??174号文/"
dir_3 = f"{local_temp_dir}/生技**174号文/"
dir_4 = f"{local_temp_dir}/生技_=+&^%#174号文/"
os.makedirs(dir_2)
os.makedirs(dir_3)
os.makedirs(dir_4)
with open(f"{dir_2}/test.txt", "w") as f:
f.write("hello world")
tosfs.put(
local_temp_dir,
f"{bucket}/{temporary_workspace}",
recursive=True,
disable_glob=True,
)
assert tosfs.exists(
f"{bucket}/{temporary_workspace}/{os.path.basename(local_temp_dir)}"
f"/生技??174号文/"
)
assert tosfs.exists(
f"{bucket}/{temporary_workspace}/{os.path.basename(local_temp_dir)}"
f"/生技??174号文/test.txt"
)
assert tosfs.exists(
f"{bucket}/{temporary_workspace}/{os.path.basename(local_temp_dir)}"
f"/生技**174号文/"
)
assert tosfs.exists(
f"{bucket}/{temporary_workspace}/{os.path.basename(local_temp_dir)}"
f"/生技_=+&^%#174号文/"
)
with tosfs.open(
f"{bucket}/{temporary_workspace}/"
f"{os.path.basename(local_temp_dir)}/生技??174号文/test.txt",
mode="r",
) as file:
assert file.read() == "hello world"

# test let special-char dir as the lpath
with tempfile.TemporaryDirectory() as local_temp_dir:
Expand Down

0 comments on commit fcf105c

Please sign in to comment.