AWSLambda - refactor exception handling

This commit is contained in:
Bert Blommers 2019-11-17 10:59:20 +00:00
commit c6dd3c96ea
4 changed files with 56 additions and 42 deletions

View file

@ -4,6 +4,7 @@ import os
import json
import boto
import boto3
import boto.iam
import boto.s3
import boto.s3.key
@ -19,9 +20,9 @@ from moto import (
mock_cloudformation_deprecated,
mock_s3_deprecated,
mock_route53_deprecated,
mock_iam,
)
from moto.cloudformation import cloudformation_backends
from moto.iam import mock_iam_deprecated
dummy_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -596,9 +597,8 @@ def test_create_stack_kinesis():
def get_role_name():
with mock_iam_deprecated():
iam = boto.connect_iam()
role = iam.create_role("my-role")["create_role_response"]["create_role_result"][
"role"
]["arn"]
return role
with mock_iam():
iam = boto3.client("iam")
return iam.create_role(
RoleName="TestRole", AssumeRolePolicyDocument="some_policy"
)["Role"]["Arn"]