def test_save_blob_file_direct(tmpdir, blob): tmpdir = Path(str(tmpdir)) fname = str(tmpdir / "file.txt") mode = "rt" if isinstance(blob, str) else "rb" assert _save_blob_to_file(blob, fname) == (fname, True) assert slurp(fname, mode=mode) == blob fname = str(tmpdir / "missing" / "file.txt") assert _save_blob_to_file(blob, fname) == (fname, False)
def test_save_blob_file(tmpdir, blob, dask_client): tmpdir = Path(str(tmpdir)) fname = str(tmpdir / "file.txt") dask_blob = dask.delayed(blob) mode = "rt" if isinstance(blob, str) else "rb" rr = save_blob_to_file(dask_blob, fname) assert dask_client.compute(rr).result() == (fname, True) assert slurp(fname, mode=mode) == blob fname = str(tmpdir / "missing" / "file.txt") rr = save_blob_to_file(dask_blob, fname) assert dask_client.compute(rr).result() == (fname, False)