Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse empty XML string nodes as an empty Python string #506

Merged
merged 2 commits into from
Apr 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>"
}
}
]
}
]
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
{
"ResponseMetadata": {
"RequestId": "bd78c839-0895-4fac-a17f-98b559b6b630"
},
},
"NetworkInterface": {
"Status": "pending",
"MacAddress": "02:74:b0:70:7f:1a",
"SourceDestCheck": true,
"VpcId": "vpc-c31dafaa",
"Description": null,
"NetworkInterfaceId": "eni-1bcb7772",
"Status": "pending",
"MacAddress": "02:74:b0:70:7f:1a",
"SourceDestCheck": true,
"VpcId": "vpc-c31dafaa",
"Description": "",
"NetworkInterfaceId": "eni-1bcb7772",
"PrivateIpAddresses": [
{
"Primary": true,
"Primary": true,
"PrivateIpAddress": "10.0.2.140"
},
},
{
"Primary": false,
"Primary": false,
"PrivateIpAddress": "10.0.2.172"
},
},
{
"Primary": false,
"Primary": false,
"PrivateIpAddress": "10.0.2.169"
},
},
{
"Primary": false,
"Primary": false,
"PrivateIpAddress": "10.0.2.170"
},
},
{
"Primary": false,
"Primary": false,
"PrivateIpAddress": "10.0.2.171"
}
],
"RequesterManaged": false,
"AvailabilityZone": "ap-southeast-1b",
],
"RequesterManaged": false,
"AvailabilityZone": "ap-southeast-1b",
"Groups": [
{
"GroupName": "default",
"GroupName": "default",
"GroupId": "sg-1a2b3c4d"
}
],
"SubnetId": "subnet-a61dafcf",
"OwnerId": "251839141158",
"TagSet": [],
],
"SubnetId": "subnet-a61dafcf",
"OwnerId": "251839141158",
"TagSet": [],
"PrivateIpAddress": "10.0.2.140"
}
}
14 changes: 7 additions & 7 deletions tests/unit/response_parsing/xml/responses/ec2-create-volume.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"AvailabilityZone": "us-east-1a",
"AvailabilityZone": "us-east-1a",
"ResponseMetadata": {
"RequestId": "59dbff89-35bd-4eac-99ed-be587EXAMPLE"
},
"VolumeType": "standard",
"VolumeId": "vol-1a2b3c4d",
"State": "creating",
"SnapshotId": null,
"CreateTime": "YYYY-MM-DDTHH:MM:SS.000Z",
},
"VolumeType": "standard",
"VolumeId": "vol-1a2b3c4d",
"State": "creating",
"SnapshotId": "",
"CreateTime": "YYYY-MM-DDTHH:MM:SS.000Z",
"Size": 80
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"Addresses": [
{
"PublicIp": "54.245.81.77",
"InstanceId": null,
"InstanceId": "",
"Domain": "standard"
},
{
"PublicIp": "54.245.99.8",
"InstanceId": null,
"InstanceId": "",
"Domain": "standard"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"Monitoring": {
"State": "disabled"
},
"PublicDnsName": null,
"PublicDnsName": "",
"KernelId": "aki-98e26fa8",
"State": {
"Code": 80,
Expand All @@ -26,20 +26,20 @@
"StateTransitionReason": "User initiated (2013-03-01 17:24:16 GMT)",
"InstanceId": "i-fde9cece",
"ImageId": "ami-30fe7300",
"PrivateDnsName": null,
"PrivateDnsName": "",
"KeyName": "aws",
"SecurityGroups": [
{
"GroupName": "notebook",
"GroupId": "sg-4e970e7e"
}
],
"ClientToken": null,
"ClientToken": "",
"InstanceType": "m1.small",
"NetworkInterfaces": [],
"Placement": {
"Tenancy": "default",
"GroupName": null,
"GroupName": "",
"AvailabilityZone": "us-west-2a"
},
"Hypervisor": "xen",
Expand All @@ -64,7 +64,7 @@
"RootDeviceType": "ebs",
"Tags": [
{
"Value": null,
"Value": "",
"Key": "notebook"
}
],
Expand Down Expand Up @@ -97,7 +97,7 @@
"PublicIpAddress": "54.245.16.142",
"PrivateIpAddress": "10.253.17.74",
"ProductCodes": [],
"StateTransitionReason": null,
"StateTransitionReason": "",
"InstanceId": "i-78f1b94a",
"ImageId": "ami-c4d643f4",
"PrivateDnsName": "ip-10-253-17-74.us-west-2.compute.internal",
Expand All @@ -113,7 +113,7 @@
"NetworkInterfaces": [],
"Placement": {
"Tenancy": "default",
"GroupName": null,
"GroupName": "",
"AvailabilityZone": "us-west-2b"
},
"Hypervisor": "xen",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"InstanceOwnerId": "123456789012",
"Status": "attached"},
"AvailabilityZone": "ap-southeast-1b",
"Description": null,
"Description": "",
"Groups": [{"GroupId": "sg-3f4b5653",
"GroupName": "default"}],
"MacAddress": "02:81:60:cb:27:37",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"OwnerId": "123456789012"
},
{
"Description": null,
"Description": "",
"VolumeId": "vol-213dd14a",
"State": "completed",
"VolumeSize": 90,
Expand All @@ -24,7 +24,7 @@
"OwnerId": "123456789012"
},
{
"Description": null,
"Description": "",
"VolumeId": "vol-4ab8dc22",
"State": "completed",
"VolumeSize": 8,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"ResourceType": "instance",
"ResourceId": "i-fde9cece",
"Value": null,
"Value": "",
"Key": "notebook"
}
]
Expand Down
30 changes: 15 additions & 15 deletions tests/unit/response_parsing/xml/responses/ec2-import-instance.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
{
"ConversionTask": {
"ConversionTaskId": "import-i-ffvko9js",
"ConversionTaskId": "import-i-ffvko9js",
"ImportInstance": {
"InstanceId": "i-12655a7f",
"Description": null,
"InstanceId": "i-12655a7f",
"Description": "",
"Volumes": [
{
"Status": "active",
"AvailabilityZone": "us-east-1a",
"Description": null,
"Status": "active",
"AvailabilityZone": "us-east-1a",
"Description": "",
"Image": {
"Size": 1179593728,
"ImportManifestUrl": "https://s3.amazonaws.com/myawsbucket/a3a5e1b6-590d-43cc-97c1-15c7325d3f41/Win_2008_Server_Data_Center_SP2_32-bit.vmdkmanifest.xml?AWSaccessKeyId=AKIAIOSFODNN7EXAMPLE%26Expires=1294855591%26Signature=5snej01T1TtL0uR7KExtEXAMPLE%3D",
"Size": 1179593728,
"ImportManifestUrl": "https://s3.amazonaws.com/myawsbucket/a3a5e1b6-590d-43cc-97c1-15c7325d3f41/Win_2008_Server_Data_Center_SP2_32-bit.vmdkmanifest.xml?AWSaccessKeyId=AKIAIOSFODNN7EXAMPLE%26Expires=1294855591%26Signature=5snej01T1TtL0uR7KExtEXAMPLE%3D",
"Format": "VMDK"
},
},
"Volume": {
"Id": "vol-1a2b3c4d",
"Id": "vol-1a2b3c4d",
"Size": 12
},
"BytesConverted": 0,
"StatusMessage": null
},
"BytesConverted": 0,
"StatusMessage": ""
}
]
},
},
"ExpirationTime": "2010-12-22T12:01Z"
},
},
"ResponseMetadata": {"RequestId": "7a62c49f-347e-4fc4-9331-6e8eEXAMPLE"}
}
Loading