This commit is contained in:
Bert Blommers 2020-05-04 09:27:57 +01:00
parent 1cda64e9a3
commit d6875c25cc
2 changed files with 13 additions and 7 deletions

View File

@ -57,7 +57,7 @@ class Deployment(BaseModel, dict):
class IntegrationResponse(BaseModel, dict):
def __init__(self, status_code, selection_pattern=None, response_templates=None):
if response_templates == None:
if response_templates is None:
response_templates = {"application/json": None}
self["responseTemplates"] = response_templates
self["statusCode"] = status_code
@ -74,10 +74,14 @@ class Integration(BaseModel, dict):
self["requestTemplates"] = request_templates
self["integrationResponses"] = {"200": IntegrationResponse(200)}
def create_integration_response(self, status_code, selection_pattern, response_templates):
def create_integration_response(
self, status_code, selection_pattern, response_templates
):
if response_templates == {}:
response_templates = None
integration_response = IntegrationResponse(status_code, selection_pattern, response_templates)
integration_response = IntegrationResponse(
status_code, selection_pattern, response_templates
)
self["integrationResponses"][status_code] = integration_response
return integration_response

View File

@ -1230,6 +1230,7 @@ def test_put_integration_response_requires_responseTemplate():
responseTemplates={},
)
@mock_apigateway
def test_put_integration_response_with_response_template():
client = boto3.client("apigateway", region_name="us-west-2")
@ -1268,9 +1269,9 @@ def test_put_integration_response_with_response_template():
resourceId=root_id,
httpMethod="GET",
statusCode="200",
selectionPattern= "foobar",
responseTemplates={"application/json": json.dumps({"data":"test"})})
selectionPattern="foobar",
responseTemplates={"application/json": json.dumps({"data": "test"})},
)
response = client.get_integration_response(
restApiId=api_id, resourceId=root_id, httpMethod="GET", statusCode="200"
@ -1284,10 +1285,11 @@ def test_put_integration_response_with_response_template():
"statusCode": "200",
"selectionPattern": "foobar",
"ResponseMetadata": {"HTTPStatusCode": 200},
"responseTemplates": {"application/json": json.dumps({"data":"test"})},
"responseTemplates": {"application/json": json.dumps({"data": "test"})},
}
)
@mock_apigateway
def test_put_integration_validation():
client = boto3.client("apigateway", region_name="us-west-2")