From e6f514825097d221883f38af9ca476849221877d Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Tue, 25 Nov 2014 15:25:34 -0800 Subject: [PATCH] Add tests for boto_call decorator Signed-off-by: Josh Durgin --- radosgw_agent/tests/test_client.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) 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() -- 2.47.3