def test_glob_walk_invalidate_cache(azure): with azure_teardown(azure): azure.mkdir(test_dir / 'c') azure.mkdir(test_dir / 'c' / 'd') filenames = ['a', 'a1', 'a2', 'a3', 'b1', 'c/x1', 'c/x2', 'c/d/x3'] filenames = [test_dir / s for s in filenames] for fn in filenames: azure.touch(fn) assert set(azure.glob(test_dir / 'a*')) == { posix(test_dir / 'a'), posix(test_dir / 'a1'), posix(test_dir / 'a2'), posix(test_dir / 'a3')} assert set(azure.glob(test_dir / 'c' / '*')) == { posix(test_dir / 'c' / 'x1'), posix(test_dir / 'c' / 'x2')} assert (set(azure.glob(test_dir / 'c')) == set(azure.glob(test_dir / 'c' / ''))) assert set(azure.glob(test_dir / 'a')) == {posix(test_dir / 'a')} assert set(azure.glob(test_dir / 'a1')) == {posix(test_dir / 'a1')} assert set(azure.glob(test_dir / '*')) == { posix(test_dir / 'a'), posix(test_dir / 'a1'), posix(test_dir / 'a2'), posix(test_dir / 'a3'), posix(test_dir / 'b1')} assert set(azure.walk(test_dir, invalidate_cache=True)) == { posix(test_dir / 'a'), posix(test_dir / 'a1'), posix(test_dir / 'a2'), posix(test_dir / 'a3'), posix(test_dir / 'b1'), posix(test_dir / 'c' / 'x1'), posix(test_dir / 'c' / 'x2'), posix(test_dir / 'c' / 'd' / 'x3')} assert set(azure.walk(test_dir / 'c', invalidate_cache=True)) == { posix(test_dir / 'c' / 'x1'), posix(test_dir / 'c' / 'x2'), posix(test_dir / 'c' / 'd' / 'x3')} assert set(azure.walk(test_dir / 'c', invalidate_cache=True)) == set(azure.walk(test_dir / 'c', invalidate_cache=True)) # test glob and walk with details=True glob_details = azure.glob(test_dir / '*', details=True, invalidate_cache=True) # validate that the objects are subscriptable assert glob_details[0]['name'] is not None assert glob_details[0]['type'] is not None walk_details = azure.walk(test_dir, details=True, invalidate_cache=True) assert walk_details[0]['name'] is not None assert walk_details[0]['type'] is not None
def test_remove_acl_entries_recursive(azure): with setup_tree(azure): acluser = AZURE_ACL_TEST_APPID permission = "rwx" azure.modify_acl_entries(test_dir, acl_spec="user:"******":" + permission, recursive=True) files = list(azure.walk(test_dir)) directories = list(set([x[0] for x in map(os.path.split, files)])) for path in files + directories: current_acl = azure.get_acl_status(path) acl_user_entry = [ s for s in current_acl['entries'] if acluser in s ] assert acl_user_entry != [] azure.remove_acl_entries(test_dir, acl_spec="user:" + acluser, recursive=True) for path in files + directories: current_acl = azure.get_acl_status(path) acl_user_entry = [ s for s in current_acl['entries'] if acluser in s ] assert acl_user_entry == []
def test_modify_acl_entries_recursive(azure): with setup_tree(azure): acluser = AZURE_ACL_TEST_APPID def check_acl_perms(path, permission): current_acl = azure.get_acl_status(path) acl_user_entry = [ s for s in current_acl['entries'] if acluser in s ] assert len(acl_user_entry) == 1 assert acl_user_entry[0].split(':')[-1] == permission files = list(azure.walk(test_dir)) directories = list(set([x[0] for x in map(os.path.split, files)])) permission = "---" azure.modify_acl_entries(test_dir, acl_spec="user:"******":" + permission, recursive=True) for path in files + directories: check_acl_perms(path, permission) permission = "rwx" azure.modify_acl_entries(test_dir, acl_spec="user:"******":" + permission, recursive=True) for path in files + directories: check_acl_perms(path, permission)