Remove HTTPHeaders from ResponseMetadata in some tests

botocore 1.4.29 started adding this. I'd match against it, but it
contains a date object and it's just not worth rewriting the assertions
for a key-by-key approach.
This commit is contained in:
Andrew Garrett 2016-06-29 23:45:21 +00:00
parent a9e54482fc
commit aab137ae66
3 changed files with 21 additions and 1 deletions

View File

@ -76,6 +76,7 @@ def test_create_resource():
restApiId=api_id, restApiId=api_id,
resourceId=root_id, resourceId=root_id,
) )
root_resource['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it
root_resource.should.equal({ root_resource.should.equal({
'path': '/', 'path': '/',
'id': root_id, 'id': root_id,
@ -133,6 +134,7 @@ def test_child_resource():
restApiId=api_id, restApiId=api_id,
resourceId=tags_id, resourceId=tags_id,
) )
child_resource['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it
child_resource.should.equal({ child_resource.should.equal({
'path': '/users/tags', 'path': '/users/tags',
'pathPart': 'tags', 'pathPart': 'tags',
@ -168,6 +170,7 @@ def test_create_method():
httpMethod='GET' httpMethod='GET'
) )
response['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it
response.should.equal({ response.should.equal({
'httpMethod': 'GET', 'httpMethod': 'GET',
'authorizationType': 'none', 'authorizationType': 'none',
@ -206,6 +209,7 @@ def test_create_method_response():
httpMethod='GET', httpMethod='GET',
statusCode='200', statusCode='200',
) )
response['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it
response.should.equal({ response.should.equal({
'ResponseMetadata': {'HTTPStatusCode': 200}, 'ResponseMetadata': {'HTTPStatusCode': 200},
'statusCode': '200' 'statusCode': '200'
@ -217,6 +221,7 @@ def test_create_method_response():
httpMethod='GET', httpMethod='GET',
statusCode='200', statusCode='200',
) )
response['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it
response.should.equal({ response.should.equal({
'ResponseMetadata': {'HTTPStatusCode': 200}, 'ResponseMetadata': {'HTTPStatusCode': 200},
'statusCode': '200' 'statusCode': '200'
@ -228,6 +233,7 @@ def test_create_method_response():
httpMethod='GET', httpMethod='GET',
statusCode='200', statusCode='200',
) )
response['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it
response.should.equal({'ResponseMetadata': {'HTTPStatusCode': 200}}) response.should.equal({'ResponseMetadata': {'HTTPStatusCode': 200}})
@ -264,6 +270,7 @@ def test_integrations():
type='HTTP', type='HTTP',
uri='http://httpbin.org/robots.txt', uri='http://httpbin.org/robots.txt',
) )
response['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it
response.should.equal({ response.should.equal({
'ResponseMetadata': {'HTTPStatusCode': 200}, 'ResponseMetadata': {'HTTPStatusCode': 200},
'httpMethod': 'GET', 'httpMethod': 'GET',
@ -284,6 +291,7 @@ def test_integrations():
resourceId=root_id, resourceId=root_id,
httpMethod='GET' httpMethod='GET'
) )
response['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it
response.should.equal({ response.should.equal({
'ResponseMetadata': {'HTTPStatusCode': 200}, 'ResponseMetadata': {'HTTPStatusCode': 200},
'httpMethod': 'GET', 'httpMethod': 'GET',
@ -303,6 +311,7 @@ def test_integrations():
restApiId=api_id, restApiId=api_id,
resourceId=root_id, resourceId=root_id,
) )
response['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it
response['resourceMethods']['GET']['methodIntegration'].should.equal({ response['resourceMethods']['GET']['methodIntegration'].should.equal({
'httpMethod': 'GET', 'httpMethod': 'GET',
'integrationResponses': { 'integrationResponses': {
@ -371,6 +380,7 @@ def test_integration_response():
statusCode='200', statusCode='200',
selectionPattern='foobar', selectionPattern='foobar',
) )
response['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it
response.should.equal({ response.should.equal({
'statusCode': '200', 'statusCode': '200',
'selectionPattern': 'foobar', 'selectionPattern': 'foobar',
@ -386,6 +396,7 @@ def test_integration_response():
httpMethod='GET', httpMethod='GET',
statusCode='200', statusCode='200',
) )
response['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it
response.should.equal({ response.should.equal({
'statusCode': '200', 'statusCode': '200',
'selectionPattern': 'foobar', 'selectionPattern': 'foobar',
@ -400,6 +411,7 @@ def test_integration_response():
resourceId=root_id, resourceId=root_id,
httpMethod='GET', httpMethod='GET',
) )
response['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it
response['methodIntegration']['integrationResponses'].should.equal({ response['methodIntegration']['integrationResponses'].should.equal({
'200': { '200': {
'responseTemplates': { 'responseTemplates': {
@ -444,6 +456,7 @@ def test_deployment():
restApiId=api_id, restApiId=api_id,
deploymentId=deployment_id, deploymentId=deployment_id,
) )
response['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it
response.should.equal({ response.should.equal({
'id': deployment_id, 'id': deployment_id,
'ResponseMetadata': {'HTTPStatusCode': 200} 'ResponseMetadata': {'HTTPStatusCode': 200}

View File

@ -86,6 +86,7 @@ def test_create_function_from_aws_bucket():
"SubnetIds": ["subnet-123abc"], "SubnetIds": ["subnet-123abc"],
}, },
) )
result['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it
result.should.equal({ result.should.equal({
'FunctionName': 'testFunction', 'FunctionName': 'testFunction',
'FunctionArn': 'arn:aws:lambda:123456789012:function:testFunction', 'FunctionArn': 'arn:aws:lambda:123456789012:function:testFunction',
@ -128,6 +129,7 @@ def test_create_function_from_zipfile():
MemorySize=128, MemorySize=128,
Publish=True, Publish=True,
) )
result['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it
result.should.equal({ result.should.equal({
'FunctionName': 'testFunction', 'FunctionName': 'testFunction',
'FunctionArn': 'arn:aws:lambda:123456789012:function:testFunction', 'FunctionArn': 'arn:aws:lambda:123456789012:function:testFunction',
@ -177,6 +179,7 @@ def test_get_function():
) )
result = conn.get_function(FunctionName='testFunction') result = conn.get_function(FunctionName='testFunction')
result['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it
result.should.equal({ result.should.equal({
"Code": { "Code": {
@ -232,6 +235,7 @@ def test_delete_function():
) )
success_result = conn.delete_function(FunctionName='testFunction') success_result = conn.delete_function(FunctionName='testFunction')
success_result['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it
success_result.should.equal({'ResponseMetadata': {'HTTPStatusCode': 204}}) success_result.should.equal({'ResponseMetadata': {'HTTPStatusCode': 204}})
conn.delete_function.when.called_with(FunctionName='testFunctionThatDoesntExist').should.throw(botocore.client.ClientError) conn.delete_function.when.called_with(FunctionName='testFunctionThatDoesntExist').should.throw(botocore.client.ClientError)
@ -295,7 +299,9 @@ def test_list_create_list_get_delete_list():
} }
conn.list_functions()['Functions'].should.equal([expected_function_result['Configuration']]) conn.list_functions()['Functions'].should.equal([expected_function_result['Configuration']])
conn.get_function(FunctionName='testFunction').should.equal(expected_function_result) func = conn.get_function(FunctionName='testFunction')
func['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it
func.should.equal(expected_function_result)
conn.delete_function(FunctionName='testFunction') conn.delete_function(FunctionName='testFunction')
conn.list_functions()['Functions'].should.have.length_of(0) conn.list_functions()['Functions'].should.have.length_of(0)

View File

@ -56,6 +56,7 @@ def test_delete_nat_gateway():
nat_gateway_id = nat_gateway['NatGateway']['NatGatewayId'] nat_gateway_id = nat_gateway['NatGateway']['NatGatewayId']
response = conn.delete_nat_gateway(NatGatewayId=nat_gateway_id) response = conn.delete_nat_gateway(NatGatewayId=nat_gateway_id)
response['ResponseMetadata'].pop('HTTPHeaders') # this is hard to match against, so remove it
response.should.equal({ response.should.equal({
'NatGatewayId': nat_gateway_id, 'NatGatewayId': nat_gateway_id,
'ResponseMetadata': { 'ResponseMetadata': {