def test_create_function_fails_after_max_retries(self, stubbed_session):
kwargs = {
'FunctionName': 'name',
'Runtime': 'python2.7',
'Code': {'ZipFile': b'foo'},
'Handler': 'app.app',
'Role': 'myarn',
}
for _ in range(TypedAWSClient.LAMBDA_CREATE_ATTEMPTS):
stubbed_session.stub('lambda').create_function(
**kwargs).raises_error(
error_code='InvalidParameterValueException',
message=('The role defined for the function cannot '
'be assumed by Lambda.')
)
stubbed_session.activate_stubs()
awsclient = TypedAWSClient(stubbed_session, mock.Mock(spec=time.sleep))
with pytest.raises(LambdaClientError) as excinfo:
awsclient.create_function('name', 'myarn', b'foo', 'python2.7',
'app.app')
assert isinstance(
excinfo.value.original_error, botocore.exceptions.ClientError)
stubbed_session.verify_stubs()
评论列表
文章目录