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)
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)
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)
def test_copy_invalid_parameter(): with pytest.raises(SystemExit): main() delete_from_oss(oss_endpoint, tmp_file)
def test_copy(): main() delete_from_oss(oss_endpoint, tmp_file)
def test_upload(): main() delete_from_oss(oss_endpoint, tmp_file)