From: Josh Durgin Date: Tue, 25 Nov 2014 23:25:34 +0000 (-0800) Subject: Add tests for boto_call decorator X-Git-Tag: v1.2~5^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e6f514825097d221883f38af9ca476849221877d;p=radosgw-agent.git Add tests for boto_call decorator Signed-off-by: Josh Durgin --- diff --git a/radosgw_agent/tests/test_client.py b/radosgw_agent/tests/test_client.py index bcc67b6..d3d3311 100644 --- a/radosgw_agent/tests/test_client.py +++ b/radosgw_agent/tests/test_client.py @@ -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()