Exemplo n.º 1
0
def test_copy_local_single_file_to_platform_file(helper: Helper,
                                                 data: _Data) -> None:
    # case when copy happens with rename to 'different_name.txt'
    srcfile, checksum = data
    file_name = str(PurePath(srcfile).name)

    helper.mkdir("folder", parents=True)
    # Upload local file to platform
    helper.run_cli([
        "storage", "cp", srcfile,
        helper.tmpstorage + "/folder/different_name.txt"
    ])

    # Ensure file is there
    helper.check_file_exists_on_storage("different_name.txt", "folder",
                                        FILE_SIZE_B)
    helper.check_file_absent_on_storage(file_name, "folder")
Exemplo n.º 2
0
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, "")