Ejemplo n.º 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)
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
 def run():
     if len(sys.argv) < 4:
         print(Delete.HELP_TEXT)
         exit(1)
     endpoint, remote = sys.argv[2:4]
     return delete_from_oss(endpoint, remote)
Ejemplo n.º 6
0
def test_copy_invalid_parameter():
    with pytest.raises(SystemExit):
        main()
        delete_from_oss(oss_endpoint, tmp_file)
Ejemplo n.º 7
0
def test_copy():
    main()
    delete_from_oss(oss_endpoint, tmp_file)
Ejemplo n.º 8
0
def test_upload():
    main()
    delete_from_oss(oss_endpoint, tmp_file)