The idea is to patch connect_to_region()
so that it returns a Mock
object, then you can define whatever methods you want on the mock, example:
import unittest
from mock import patch, Mock
class MyTestCase(unittest.TestCase):
@patch('boto.beanstalk.connect_to_region')
def test_boto(self, connect_mock):
eb = Mock()
eb.create_storage_location.return_value = 'test'
connect_mock.return_value = eb
to_be_tested = ToBeTested()
# assertions
See also:
Hope that helps.