]> git-server-git.apps.pok.os.sepia.ceph.com Git - radosgw-agent.git/commitdiff
Add tests for boto_call decorator
authorJosh Durgin <jdurgin@redhat.com>
Tue, 25 Nov 2014 23:25:34 +0000 (15:25 -0800)
committerJosh Durgin <jdurgin@redhat.com>
Tue, 25 Nov 2014 23:25:34 +0000 (15:25 -0800)
Signed-off-by: Josh Durgin <jdurgin@redhat.com>
radosgw_agent/tests/test_client.py

index bcc67b6f32a7ae22cf0ffa2e47c2936771146ee1..d3d331106996d70767f5d146f1f4bbd81765adc9 100644 (file)
@@ -1,3 +1,4 @@
+import boto
 import py.test
 from mock import Mock
 
@@ -351,3 +352,28 @@ class TestCheckResultStatus(object):
         with py.test.raises(client.NotFound):
             client.check_result_status(response)
 
+
+class TestBotoCall(object):
+
+    def test_return_val(self):
+        @client.boto_call
+        def foo(*args, **kwargs):
+            return (args, kwargs)
+        assert foo(1) == ((1,), {})
+        assert foo(b=2) == (tuple(), {'b': 2})
+
+    def test_boto_exception_not_found(self):
+        @client.boto_call
+        def foo():
+            raise boto.exception.S3ResponseError(404, '')
+
+        with py.test.raises(client.NotFound):
+            foo()
+
+    def test_non_boto_exception(self):
+        @client.boto_call
+        def foo():
+            raise ValueError('')
+
+        with py.test.raises(ValueError):
+            foo()