def test_e2e_copy_recursive_to_platform(helper: Helper, nested_data: Tuple[str, str, str], tmp_path: Path) -> None: helper.mkdir("") srcfile, checksum, dir_path = nested_data target_file_name = Path(srcfile).name # Upload local file captured = helper.run_cli( ["storage", "cp", "-r", dir_path, helper.tmpstorage]) # stderr has logs like "Using path ..." # assert not captured.err assert not captured.out helper.check_file_exists_on_storage(target_file_name, f"nested/directory/for/test", FILE_SIZE_B // 3) # Download into local directory and confirm checksum targetdir = tmp_path / "bar" targetdir.mkdir() helper.run_cli( ["storage", "cp", "-r", f"{helper.tmpstorage}", str(targetdir)]) targetfile = targetdir / "nested" / "directory" / "for" / "test" / target_file_name print("source file", srcfile) print("target file", targetfile) assert helper.hash_hex(targetfile) == checksum
def test_copy_and_remove_multiple_files(helper: Helper, data2: _Data, data3: _Data, tmp_path: Path) -> None: helper.mkdir("") # case when copy happens with rename to 'different_name.txt' srcfile, checksum = data2 srcfile2, checksum2 = data3 srcname = os.path.basename(srcfile) srcname2 = os.path.basename(srcfile2) # Upload local files captured = helper.run_cli( ["storage", "cp", srcfile, srcfile2, helper.tmpstorage]) assert captured.out == "" # Confirm files has been uploaded helper.check_file_exists_on_storage(srcname, "", FILE_SIZE_B // 3) helper.check_file_exists_on_storage(srcname2, "", FILE_SIZE_B // 5) # Download into local directory and confirm checksum targetdir = tmp_path / "bar" targetdir.mkdir() helper.run_cli([ "storage", "cp", f"{helper.tmpstorage}/{srcname}", f"{helper.tmpstorage}/{srcname2}", str(targetdir), ]) assert helper.hash_hex(targetdir / srcname) == checksum assert helper.hash_hex(targetdir / srcname2) == checksum2 # Remove the files from platform captured = helper.run_cli([ "storage", "rm", f"{helper.tmpstorage}/{srcname}", f"{helper.tmpstorage}/{srcname2}", ]) assert captured.out == "" # Ensure files are not there helper.check_file_absent_on_storage(srcname, "") helper.check_file_absent_on_storage(srcname2, "")
def test_e2e_blob_storage_copy_recursive_folder( helper: Helper, nested_data: Tuple[str, str, str], tmp_path: Path, tmp_bucket: str ) -> None: srcfile, checksum, dir_path = nested_data target_file_name = Path(srcfile).name # Upload local folder .../neested_data/nested to bucket root captured = helper.run_cli(["blob", "cp", "-r", dir_path, f"blob:{tmp_bucket}"]) # stderr has logs like "Using path ..." # assert not captured.err assert not captured.out helper.check_blob_size( tmp_bucket, f"nested/directory/for/test/{target_file_name}", FILE_SIZE_B // 3 ) # Download into local directory and confirm checksum targetdir = tmp_path / "bar" targetdir.mkdir() helper.run_cli(["blob", "cp", "-r", f"blob:{tmp_bucket}/", str(targetdir)]) targetfile = targetdir / "nested" / "directory" / "for" / "test" / target_file_name assert helper.hash_hex(targetfile) == checksum