Skip to content

Commit

Permalink
Parse empty XML string nodes as an empty Python string
Browse files Browse the repository at this point in the history
This changes the output of the XML-based parsers and adds protocol tests for
each of `query`, `ec2`, and `rest-xml`. This is required to support new
waiters as in aws/aws-cli#1252.
  • Loading branch information
danielgtaylor committed Mar 31, 2015
1 parent fbbc94d commit e134d9a
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 5 deletions.
5 changes: 0 additions & 5 deletions botocore/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,6 @@ def _inject_response_metadata(self, node, inject_into):
sub_mapping[key] = value.text
inject_into['ResponseMetadata'] = sub_mapping

def _handle_string(self, shape, node):
return node.text

_handle_character = _handle_string


class EC2QueryParser(QueryParser):

Expand Down
37 changes: 37 additions & 0 deletions tests/unit/protocols/output/ec2.json
Original file line number Diff line number Diff line change
Expand Up @@ -413,5 +413,42 @@
}
}
]
},
{
"description": "Empty string",
"metadata": {
"protocol": "ec2"
},
"shapes": {
"OutputShape": {
"type": "structure",
"members": {
"Foo": {
"shape": "StringType"
}
}
},
"StringType": {
"type": "string"
}
},
"cases": [
{
"given": {
"output": {
"shape": "OutputShape"
},
"name": "OperationName"
},
"result": {
"Foo": ""
},
"response": {
"status_code": 200,
"headers": {},
"body": "<OperationNameResponse><Foo/><RequestId>requestid</RequestId></OperationNameResponse>"
}
}
]
}
]
37 changes: 37 additions & 0 deletions tests/unit/protocols/output/query.json
Original file line number Diff line number Diff line change
Expand Up @@ -772,5 +772,42 @@
}
}
]
},
{
"description": "Empty string",
"metadata": {
"protocol": "query"
},
"shapes": {
"OutputShape": {
"type": "structure",
"members": {
"Foo": {
"shape": "StringType"
}
}
},
"StringType": {
"type": "string"
}
},
"cases": [
{
"given": {
"output": {
"shape": "OutputShape"
},
"name": "OperationName"
},
"result": {
"Foo": ""
},
"response": {
"status_code": 200,
"headers": {},
"body": "<OperationNameResponse><Foo/><RequestId>requestid</RequestId></OperationNameResponse>"
}
}
]
}
]
37 changes: 37 additions & 0 deletions tests/unit/protocols/output/rest-xml.json
Original file line number Diff line number Diff line change
Expand Up @@ -679,5 +679,42 @@
}
}
]
},
{
"description": "Empty string",
"metadata": {
"protocol": "rest-xml"
},
"shapes": {
"OutputShape": {
"type": "structure",
"members": {
"Foo": {
"shape": "StringType"
}
}
},
"StringType": {
"type": "string"
}
},
"cases": [
{
"given": {
"output": {
"shape": "OutputShape"
},
"name": "OperationName"
},
"result": {
"Foo": ""
},
"response": {
"status_code": 200,
"headers": {},
"body": "<OperationNameResponse><Foo/><RequestId>requestid</RequestId></OperationNameResponse>"
}
}
]
}
]

0 comments on commit e134d9a

Please sign in to comment.