From ae938223d4fb077510df81bee8db782fb6c3318f Mon Sep 17 00:00:00 2001 From: Steve Pulec Date: Sun, 24 Jul 2016 09:50:39 -0400 Subject: [PATCH] Cleanup headers popping. --- tests/test_apigateway/test_apigateway.py | 26 ++++++++++++------------ tests/test_awslambda/test_lambda.py | 10 ++++----- tests/test_ec2/test_nat_gateway.py | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/tests/test_apigateway/test_apigateway.py b/tests/test_apigateway/test_apigateway.py index 3a44f9138..1ecc0a5bb 100644 --- a/tests/test_apigateway/test_apigateway.py +++ b/tests/test_apigateway/test_apigateway.py @@ -76,7 +76,7 @@ def test_create_resource(): restApiId=api_id, resourceId=root_id, ) - root_resource['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it + root_resource['ResponseMetadata'].pop('HTTPHeaders', None) # this is hard to match against, so remove it root_resource.should.equal({ 'path': '/', 'id': root_id, @@ -134,7 +134,7 @@ def test_child_resource(): restApiId=api_id, resourceId=tags_id, ) - child_resource['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it + child_resource['ResponseMetadata'].pop('HTTPHeaders', None) # this is hard to match against, so remove it child_resource.should.equal({ 'path': '/users/tags', 'pathPart': 'tags', @@ -170,7 +170,7 @@ def test_create_method(): httpMethod='GET' ) - response['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it + response['ResponseMetadata'].pop('HTTPHeaders', None) # this is hard to match against, so remove it response.should.equal({ 'httpMethod': 'GET', 'authorizationType': 'none', @@ -209,7 +209,7 @@ def test_create_method_response(): httpMethod='GET', statusCode='200', ) - response['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it + response['ResponseMetadata'].pop('HTTPHeaders', None) # this is hard to match against, so remove it response.should.equal({ 'ResponseMetadata': {'HTTPStatusCode': 200}, 'statusCode': '200' @@ -221,7 +221,7 @@ def test_create_method_response(): httpMethod='GET', statusCode='200', ) - response['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it + response['ResponseMetadata'].pop('HTTPHeaders', None) # this is hard to match against, so remove it response.should.equal({ 'ResponseMetadata': {'HTTPStatusCode': 200}, 'statusCode': '200' @@ -233,7 +233,7 @@ def test_create_method_response(): httpMethod='GET', statusCode='200', ) - response['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it + response['ResponseMetadata'].pop('HTTPHeaders', None) # this is hard to match against, so remove it response.should.equal({'ResponseMetadata': {'HTTPStatusCode': 200}}) @@ -270,7 +270,7 @@ def test_integrations(): type='HTTP', uri='http://httpbin.org/robots.txt', ) - response['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it + response['ResponseMetadata'].pop('HTTPHeaders', None) # this is hard to match against, so remove it response.should.equal({ 'ResponseMetadata': {'HTTPStatusCode': 200}, 'httpMethod': 'GET', @@ -291,7 +291,7 @@ def test_integrations(): resourceId=root_id, httpMethod='GET' ) - response['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it + response['ResponseMetadata'].pop('HTTPHeaders', None) # this is hard to match against, so remove it response.should.equal({ 'ResponseMetadata': {'HTTPStatusCode': 200}, 'httpMethod': 'GET', @@ -311,7 +311,7 @@ def test_integrations(): restApiId=api_id, resourceId=root_id, ) - response['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it + response['ResponseMetadata'].pop('HTTPHeaders', None) # this is hard to match against, so remove it response['resourceMethods']['GET']['methodIntegration'].should.equal({ 'httpMethod': 'GET', 'integrationResponses': { @@ -380,7 +380,7 @@ def test_integration_response(): statusCode='200', selectionPattern='foobar', ) - response['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it + response['ResponseMetadata'].pop('HTTPHeaders', None) # this is hard to match against, so remove it response.should.equal({ 'statusCode': '200', 'selectionPattern': 'foobar', @@ -396,7 +396,7 @@ def test_integration_response(): httpMethod='GET', statusCode='200', ) - response['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it + response['ResponseMetadata'].pop('HTTPHeaders', None) # this is hard to match against, so remove it response.should.equal({ 'statusCode': '200', 'selectionPattern': 'foobar', @@ -411,7 +411,7 @@ def test_integration_response(): resourceId=root_id, httpMethod='GET', ) - response['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it + response['ResponseMetadata'].pop('HTTPHeaders', None) # this is hard to match against, so remove it response['methodIntegration']['integrationResponses'].should.equal({ '200': { 'responseTemplates': { @@ -456,7 +456,7 @@ def test_deployment(): restApiId=api_id, deploymentId=deployment_id, ) - response['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it + response['ResponseMetadata'].pop('HTTPHeaders', None) # this is hard to match against, so remove it response.should.equal({ 'id': deployment_id, 'ResponseMetadata': {'HTTPStatusCode': 200} diff --git a/tests/test_awslambda/test_lambda.py b/tests/test_awslambda/test_lambda.py index dd5ab8cf9..e706a013f 100644 --- a/tests/test_awslambda/test_lambda.py +++ b/tests/test_awslambda/test_lambda.py @@ -123,7 +123,7 @@ def test_create_function_from_aws_bucket(): "SubnetIds": ["subnet-123abc"], }, ) - result['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it + result['ResponseMetadata'].pop('HTTPHeaders', None) # this is hard to match against, so remove it result.should.equal({ 'FunctionName': 'testFunction', 'FunctionArn': 'arn:aws:lambda:123456789012:function:testFunction', @@ -166,7 +166,7 @@ def test_create_function_from_zipfile(): MemorySize=128, Publish=True, ) - result['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it + result['ResponseMetadata'].pop('HTTPHeaders', None) # this is hard to match against, so remove it result.should.equal({ 'FunctionName': 'testFunction', 'FunctionArn': 'arn:aws:lambda:123456789012:function:testFunction', @@ -216,7 +216,7 @@ def test_get_function(): ) result = conn.get_function(FunctionName='testFunction') - result['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it + result['ResponseMetadata'].pop('HTTPHeaders', None) # this is hard to match against, so remove it result.should.equal({ "Code": { @@ -272,7 +272,7 @@ def test_delete_function(): ) success_result = conn.delete_function(FunctionName='testFunction') - success_result['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it + success_result['ResponseMetadata'].pop('HTTPHeaders', None) # this is hard to match against, so remove it success_result.should.equal({'ResponseMetadata': {'HTTPStatusCode': 204}}) conn.delete_function.when.called_with(FunctionName='testFunctionThatDoesntExist').should.throw(botocore.client.ClientError) @@ -337,7 +337,7 @@ def test_list_create_list_get_delete_list(): conn.list_functions()['Functions'].should.equal([expected_function_result['Configuration']]) func = conn.get_function(FunctionName='testFunction') - func['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it + func['ResponseMetadata'].pop('HTTPHeaders', None) # this is hard to match against, so remove it func.should.equal(expected_function_result) conn.delete_function(FunctionName='testFunction') diff --git a/tests/test_ec2/test_nat_gateway.py b/tests/test_ec2/test_nat_gateway.py index 694f0c599..f162a9d29 100644 --- a/tests/test_ec2/test_nat_gateway.py +++ b/tests/test_ec2/test_nat_gateway.py @@ -56,7 +56,7 @@ def test_delete_nat_gateway(): nat_gateway_id = nat_gateway['NatGateway']['NatGatewayId'] response = conn.delete_nat_gateway(NatGatewayId=nat_gateway_id) - response['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it + response['ResponseMetadata'].pop('HTTPHeaders', None) # this is hard to match against, so remove it response.should.equal({ 'NatGatewayId': nat_gateway_id, 'ResponseMetadata': {