コード例 #1
0
def test_e2e_blob_storage_upload_download(
    data: Tuple[Path, str], tmp_path: Path, helper: Helper, tmp_bucket: str
) -> None:
    srcfile, checksum = data
    key = "folder/foo"

    # Upload local file
    helper.upload_blob(bucket_name=tmp_bucket, key=key, file=srcfile)

    # Confirm file has been uploaded
    helper.check_blob_size(tmp_bucket, key, FILE_SIZE_B)

    # Download into local file and confirm checksum
    helper.check_blob_checksum(tmp_bucket, key, checksum, tmp_path / "bar")
コード例 #2
0
def test_e2e_blob_storage_copy_file_to_folder_key(
    helper: Helper, data: _Data, tmp_bucket: str
) -> None:
    srcfile, checksum = data
    file_name = str(PurePath(srcfile).name)
    stub_key = "folder/bar"
    key = f"folder/{file_name}"
    folder_uri = f"blob:{tmp_bucket}/folder"

    # First upload to a nested path
    helper.upload_blob(bucket_name=tmp_bucket, key=stub_key, file=srcfile)

    # Second will succeed, but upload the file `under` the `folder`,
    # as it's a folder key
    helper.run_cli(["blob", "cp", srcfile, folder_uri])
    helper.check_blob_size(tmp_bucket, stub_key, FILE_SIZE_B)
    helper.check_blob_size(tmp_bucket, key, FILE_SIZE_B)

    # Second we do the same command, but with -T that should raise an error
    with pytest.raises(
        subprocess.CalledProcessError,
        match=f"returned non-zero exit status {EX_OSFILE}",
    ):
        helper.run_cli(["blob", "cp", "-T", srcfile, folder_uri])