def test_api_fluid(with_adapter: str, bucket: str) -> None: path: FluidPath = Pathy.fluid(f"gs://{bucket}/fake-key") assert isinstance(path, Pathy) path = Pathy.fluid("foo/bar.txt") assert isinstance(path, BasePath) path = Pathy.fluid("/dev/null") assert isinstance(path, BasePath)
def test_cli_ls_local_files(with_adapter: str, bucket: str) -> None: root = Pathy.fluid(tempfile.mkdtemp()) / "ls" root.mkdir(parents=True, exist_ok=True) for i in range(3): (root / f"file_{i}").write_text("NICE") files = list(root.ls()) assert len(files) == 3 for i, blob_stat in enumerate(files): assert blob_stat.name == f"file_{i}" assert blob_stat.size == 4 assert blob_stat.last_modified is not None root = Pathy.from_bucket(bucket) / "cli_ls" one = str(root / "file.txt") two = str(root / "other.txt") three = str(root / "folder/file.txt") Pathy(one).write_text("---") Pathy(two).write_text("---") Pathy(three).write_text("---") result = runner.invoke(app, ["ls", str(root)]) assert result.exit_code == 0 assert one in result.output assert two in result.output assert str(root / "folder") in result.output result = runner.invoke(app, ["ls", "-l", str(root)]) assert result.exit_code == 0 assert one in result.output assert two in result.output assert str(root / "folder") in result.output