Xuanwo commented on code in PR #3492: URL: https://github.com/apache/incubator-opendal/pull/3492#discussion_r1384422751
########## bindings/python/tests/test_sync_copy.py: ########## @@ -16,93 +16,97 @@ # under the License. import os -from random import randint from uuid import uuid4 import pytest -from opendal.exceptions import IsADirectory, IsSameFile, NotFound +from opendal.exceptions import Error, IsADirectory, IsSameFile, NotFound [email protected]_capability("read", "write", "copy") -def test_sync_copy(service_name, operator, async_operator): [email protected]_capability("read", "write", "rename") +def test_sync_rename_file(service_name, operator, async_operator): source_path = f"random_file_{str(uuid4())}" content = os.urandom(1024) operator.write(source_path, content) target_path = f"random_file_{str(uuid4())}" - operator.copy(source_path, target_path) - read_content = operator.read(target_path) - assert read_content is not None - assert read_content == content - operator.delete(source_path) + operator.rename(source_path, target_path) + with pytest.raises(Error) as e_info: + operator.read(source_path) + assert isinstance(e_info.value, NotFound) + assert operator.read(target_path) == content operator.delete(target_path) + operator.delete(source_path) [email protected]_capability("read", "write", "copy") -def test_sync_copy_non_exist(service_name, operator, async_operator): [email protected]_capability("read", "write", "rename") +def test_sync_rename_non_exists_file(service_name, operator, async_operator): source_path = f"random_file_{str(uuid4())}" target_path = f"random_file_{str(uuid4())}" - with pytest.raises(NotFound) as e_info: - operator.copy(source_path, target_path) + with pytest.raises(Error) as e_info: + operator.rename(source_path, target_path) + assert isinstance(e_info.value, NotFound) [email protected]_capability("read", "write", "copy") -def test_sync_copy_source_directory(service_name, operator, async_operator): [email protected]_capability("read", "write", "rename") +def test_sync_rename_directory(service_name, operator, async_operator): source_path = f"random_file_{str(uuid4())}/" operator.create_dir(source_path) target_path = f"random_file_{str(uuid4())}" - with pytest.raises(IsADirectory) as e_info: - operator.copy(source_path, target_path) + with pytest.raises(Error) as e_info: + operator.rename(source_path, target_path) + assert isinstance(e_info.value, IsADirectory) [email protected]_capability("read", "write", "copy") -def test_sync_copy_target_directory(service_name, operator, async_operator): [email protected]_capability("read", "write", "rename") +def test_sync_rename_file_to_directory(service_name, operator, async_operator): source_path = f"random_file_{str(uuid4())}" content = os.urandom(1024) operator.write(source_path, content) target_path = f"random_file_{str(uuid4())}/" - operator.create_dir(target_path) - with pytest.raises(IsADirectory) as e_info: - operator.copy(source_path, target_path) + with pytest.raises(Error) as e_info: Review Comment: How about adding a unittest instead? Our behavior tests code looks good and don't need to update. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
