def test_api_rmdir(with_adapter: str, bucket: str) -> None: Pathy(f"gs://{bucket}/rmdir/one.txt").write_text("---") Pathy(f"gs://{bucket}/rmdir/folder/two.txt").write_text("---") path = Pathy(f"gs://{bucket}/rmdir/") path.rmdir() assert not Pathy(f"gs://{bucket}/rmdir/one.txt").is_file() assert not Pathy(f"gs://{bucket}/rmdir/other/two.txt").is_file() assert not path.exists()
def test_api_mkdir(with_adapter: str, bucket: str) -> None: bucket_name = f"pathy-e2e-test-{uuid4().hex}" # Create a bucket path = Pathy(f"gs://{bucket_name}/") path.mkdir() assert path.exists() # Does not assert if it already exists path.mkdir(exist_ok=True) with pytest.raises(FileExistsError): path.mkdir(exist_ok=False) # with pytest.raises(FileNotFoundError): # Pathy("/test-second-bucket/test-directory/file.name").mkdir() # Pathy("/test-second-bucket/test-directory/file.name").mkdir(parents=True) assert path.exists() # remove the bucket # client = storage.Client() # bucket = client.lookup_bucket(bucket_name) # bucket.delete() path.rmdir() assert not path.exists()