Skip to content

Commit

Permalink
Add test for the current behaviour of expand_path
Browse files Browse the repository at this point in the history
  • Loading branch information
sgref committed Apr 6, 2022
1 parent 79beefc commit 6759a3f
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions adlfs/tests/test_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -1348,3 +1348,40 @@ def test_find_with_prefix(storage):
assert test_1s == [test_bucket_name + "/prefixes/test_1"] + [
test_bucket_name + f"/prefixes/test_{cursor}" for cursor in range(10, 20)
]


def test_expand_path(storage):
test_bucket = "data"
test_dir = f"{test_bucket}/testexpandpath"
sub_dir_1 = f"{test_dir}/subdir1"
sub_dir_2 = f"{sub_dir_1}/subdir2"
test_blobs = [
f"{test_dir}/blob1",
f"{test_dir}/blob2",
f"{test_dir}/subdir1/blob3",
f"{test_dir}/subdir1/blob4",
f"{test_dir}/subdir1/subdir2/blob5",
]

expected_dirs_w_trailing_slash = test_blobs.copy()
expected_dirs_w_trailing_slash.append(sub_dir_1 + "/")
expected_dirs_w_trailing_slash.append(sub_dir_2 + "/")

expected_dirs_wo_trailing_slash = test_blobs.copy()
expected_dirs_wo_trailing_slash.append(sub_dir_1)
expected_dirs_wo_trailing_slash.append(sub_dir_2)

fs = AzureBlobFileSystem(
account_name=storage.account_name, connection_string=CONN_STR
)
for blob in test_blobs:
fs.touch(blob)

result_without_slash = fs.expand_path(test_dir, recursive=True)
assert sorted(result_without_slash) == sorted(expected_dirs_w_trailing_slash)

result_with_slash = fs.expand_path(test_dir + "/", recursive=True)
assert sorted(result_with_slash) == sorted(expected_dirs_w_trailing_slash)

result_glob = fs.expand_path(test_dir + "/*", recursive=True)
assert sorted(result_glob) == sorted(expected_dirs_wo_trailing_slash)

0 comments on commit 6759a3f

Please sign in to comment.