This is an automated email from the ASF dual-hosted git repository.

silver pushed a commit to branch python-presign
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git


The following commit(s) were added to refs/heads/python-presign by this push:
     new c154c21ed update test for presign
c154c21ed is described below

commit c154c21ed74177fa75d959e9caae5404616b5aa2
Author: silver-ymz <[email protected]>
AuthorDate: Mon Aug 28 14:02:13 2023 +0800

    update test for presign
    
    Signed-off-by: silver-ymz <[email protected]>
---
 bindings/python/src/lib.rs              | 11 +++++++----
 bindings/python/tests/steps/binding.py  | 15 +++++++--------
 bindings/tests/features/binding.feature |  5 +----
 3 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/bindings/python/src/lib.rs b/bindings/python/src/lib.rs
index 32ba23117..4e3dc11c2 100644
--- a/bindings/python/src/lib.rs
+++ b/bindings/python/src/lib.rs
@@ -27,9 +27,11 @@ use std::str::FromStr;
 use ::opendal as od;
 use pyo3::create_exception;
 use pyo3::exceptions::PyException;
+use pyo3::exceptions::PyFileExistsError;
 use pyo3::exceptions::PyFileNotFoundError;
 use pyo3::exceptions::PyIOError;
 use pyo3::exceptions::PyNotImplementedError;
+use pyo3::exceptions::PyPermissionError;
 use pyo3::exceptions::PyValueError;
 use pyo3::prelude::*;
 use pyo3::types::PyBytes;
@@ -391,11 +393,9 @@ impl PresignedRequest {
         let mut headers = HashMap::new();
         for (k, v) in self.0.header().iter() {
             let k = k.as_str();
-            let v = v
-                .to_str()
-                .map_err(|err| PyValueError::new_err(err.to_string()))?;
+            let v = v.to_str().map_err(|err| Error::new_err(err.to_string()))?;
             if headers.insert(k, v).is_some() {
-                return Err(PyValueError::new_err("duplicate header"));
+                return Err(Error::new_err("duplicate header"));
             }
         }
         Ok(headers)
@@ -406,6 +406,9 @@ fn format_pyerr(err: od::Error) -> PyErr {
     use od::ErrorKind::*;
     match err.kind() {
         NotFound => PyFileNotFoundError::new_err(err.to_string()),
+        AlreadyExists => PyFileExistsError::new_err(err.to_string()),
+        PermissionDenied => PyPermissionError::new_err(err.to_string()),
+        Unsupported => PyNotImplementedError::new_err(err.to_string()),
         _ => Error::new_err(err.to_string()),
     }
 }
diff --git a/bindings/python/tests/steps/binding.py 
b/bindings/python/tests/steps/binding.py
index d4200bcb5..06edb9f7f 100644
--- a/bindings/python/tests/steps/binding.py
+++ b/bindings/python/tests/steps/binding.py
@@ -89,13 +89,12 @@ async def step_impl(context, filename, content):
     bs = await context.op.read(filename)
     assert bs == content.encode()
 
-@given("A new OpenDAL Async Operator (presign available)")
-def step_impl(context):
-    context.op = opendal.AsyncOperator("s3", bucket="test", 
region="us-east-1", access_key_id="test", secret_access_key="test")
-
-@then("The operator is available for presign")
+@then("The presign operation should success or raise exception Unsupported")
 @async_run_until_complete
 async def step_impl(context):
-    await context.op.presign_stat("test.txt", 10)
-    await context.op.presign_read("test.txt", 10)
-    await context.op.presign_write("test.txt", 10)
\ No newline at end of file
+    try:
+        await context.op.presign_stat("test.txt", 10)
+        await context.op.presign_read("test.txt", 10)
+        await context.op.presign_write("test.txt", 10)
+    except NotImplementedError:
+        pass
\ No newline at end of file
diff --git a/bindings/tests/features/binding.feature 
b/bindings/tests/features/binding.feature
index 83921a633..f9f02a7a7 100644
--- a/bindings/tests/features/binding.feature
+++ b/bindings/tests/features/binding.feature
@@ -32,7 +32,4 @@ Feature: OpenDAL Binding
         Then The async file "test" entry mode must be file
         Then The async file "test" content length must be 13
         Then The async file "test" must have content "Hello, World!"
-
-    Scenario: OpenDAL Async Operations with Presign
-        Given A new OpenDAL Async Operator (presign available)
-        Then The operator is available for presign
+        Then The presign operation should success or raise exception 
Unsupported

Reply via email to