Beispiel #1
0
def test_upload():
    remote_file = str(time.time())
    assert not check_file_exists(oss_endpoint, remote_file)
    upload_to_oss(cur_file, oss_endpoint, remote_file)
    assert check_file_exists(oss_endpoint, remote_file)
    delete_from_oss(oss_endpoint, remote_file)
    assert not check_file_exists(oss_endpoint, remote_file)
def test_copy_file_to_directory_name():
    target = test_file + str(time.time()) + "/"
    assert not check_file_exists(oss_endpoint, target)
    copy_file(oss_endpoint, test_file, target)
    assert check_file_exists(oss_endpoint, target)
    delete_from_oss(oss_endpoint, target)
    assert not check_file_exists(oss_endpoint, target)
def test_copy_directory():
    target = test_directory + str(time.time())
    assert not check_file_exists(oss_endpoint, target)
    copy_file(oss_endpoint, test_directory, target)
    assert check_file_exists(oss_endpoint, target)
    delete_from_oss(oss_endpoint, target)
    assert not check_file_exists(oss_endpoint, target)
Beispiel #4
0
 def run():
     if len(sys.argv) < 4:
         print(Exist.HELP_TEXT)
         exit(1)
     endpoint, remote_path = sys.argv[2:4]
     if not check_file_exists(endpoint, remote_path):
         exit(1)
Beispiel #5
0
def test_upload_directory():
    remote_dir = str(time.time())
    assert not check_file_exists(oss_endpoint, remote_dir)
    upload_to_oss(cur_dir, oss_endpoint, remote_dir)
    assert check_file_exists(oss_endpoint, remote_dir)

    local_files = []
    for top, dirs, files in os.walk(cur_dir):
        for file in files:
            file = os.path.join(top, file)
            file = os.path.relpath(file, cur_dir)
            local_files.append(file)

    remote_files = []
    for file in list_files(oss_endpoint, remote_dir):
        remote_files.append(os.path.relpath(file, remote_dir))

    assert set(local_files) == set(remote_files)

    delete_from_oss(oss_endpoint, remote_dir)
    assert not check_file_exists(oss_endpoint, remote_dir)
Beispiel #6
0
def test_exist():
    assert check_file_exists(oss_endpoint, test_file)
    assert check_file_exists(oss_endpoint, test_directory)
    assert not check_file_exists(oss_endpoint, test_file + str(time.time()))
def test_copy_directory_into_self():
    target = test_directory + "/" + "self"
    assert not check_file_exists(oss_endpoint, target)
    with pytest.raises(Exception):
        copy_file(oss_endpoint, test_directory, target)