def test_api_replace_folders_in_bucket(with_adapter: str, bucket: str) -> None: # Rename a folder in the same bucket Pathy(f"gs://{bucket}/replace/folder/one.txt").write_text("---") Pathy(f"gs://{bucket}/replace/folder/two.txt").write_text("---") path = Pathy(f"gs://{bucket}/replace/folder/") new_path = Pathy(f"gs://{bucket}/replace/other/") path.replace(new_path) assert not path.exists() assert new_path.exists() assert Pathy(f"gs://{bucket}/replace/other/one.txt").is_file() assert Pathy(f"gs://{bucket}/replace/other/two.txt").is_file()
def test_api_replace_folders_across_buckets(with_adapter, bucket: str, other_bucket: str): # Rename a folder across buckets Pathy(f"gs://{bucket}/replace/folder/one.txt").write_text("---") Pathy(f"gs://{bucket}/replace/folder/two.txt").write_text("---") path = Pathy(f"gs://{bucket}/replace/folder/") new_path = Pathy(f"gs://{other_bucket}/replace/other/") path.replace(new_path) assert not path.exists() assert new_path.exists() assert Pathy(f"gs://{other_bucket}/replace/other/one.txt").is_file() assert Pathy(f"gs://{other_bucket}/replace/other/two.txt").is_file()